So I don't know if this can be done or not but I'm have this function and with some of the variables that I get the result from I make other operations, here is the code.
x();
function x() {
if (y === "yes") {
var a = parseInt(prompt("Insert Number Here"))
var b = parseInt(prompt("Insert Number Here"))
var c = a * b
var cont = prompt("yes or no").toLowerCase();
if (cont === "yes") {
x();
} else if (cont === "total") {
alert total();
}
} else if (z === "yes") {
var d = parseInt(prompt("Insert Number Here"))
var e = parseInt(prompt("Insert Number Here"))
var f = d * e
var cont = prompt("yes or no").toLowerCase();
if (cont === "yes") {
x();
} else if (cont === "total") {
alert total();
}
}
function total() {
c = c|| 0;
f = f|| 0;
return `The total is $${c + f}`
}
}
So, when I run this it just gives the result of the last operation made