Is there a way that I can declare a variable outside the function? $first and $second can't seem to read it outside function. and 1 more thing .remove() doesn't work.
function addition(){ let $first = parseInt($('#firstNum').val()); let $second = parseInt($('#secondNum').val()); $('h1').append($first + $second); } function subtraction(){ let $first = parseInt($('#firstNum').val()); let $second = parseInt($('#secondNum').val()); $('h1').append($first - $second); } function multiplication(){ let $first = parseInt($('#firstNum').val()); let $second = parseInt($('#secondNum').val()); $('h1').append($first * $second); } function division(){ let $first = parseInt($('#firstNum').val()); let $second = parseInt($('#secondNum').val()); $('h1').append($first / $second); } function clear(){ $('h1').remove(); }``` https://stackoverflow.com/questions/65590041/is-there-a-way-that-i-can-declare-the-variable-outside-function January 06, 2021 at 12:04PM
没有评论:
发表评论