Is there a way that I can declare a variable outside the function? $first and $second can't seem to read it outside the 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();
}```