trying to build myself a calculator which takes two prompted numbers then to have a separate set of buttons to evaluate them
the problem i've encountered is the following, i take the prompted number1 and number2 and save them as variables, BUT when i try to summon the variables inside an external function, it tells me the variables (number1 and number2) are not defined
any help?
ps: i've started working on the addition button, then will add sub/mult/div, just need to get the first one going
// the user is required to choose two sets of numbers that are then stored as variables
function numRequest() {
var number1 = prompt('choose the first number to evaluate:');
var number2 = prompt('choose the second number to evaluate:');
// just an external checker to see if the prompt is being saved
console.log('first choice --> ' + number1);
console.log('second choice --> ' + number2);
// the numbers, stored as variables, are displayed on the calculator window
document.getElementById('resBanner').innerHTML = ('you chose ' + number1 + ' and ' + number2);
}
// this is where the problem arises
// when i press the button that summons the function addition(), the two numbers arent
// defined for some reason
function addition() {
var res = Number(number1) + Number(number2);
document.getElementById('resBanner').innerHTML = res;
}
// function subtraction() {}
// function division() {}
// function multiplication() {}