Entonces, no sé si esto se puede hacer o no, pero tengo esta función y con algunas de las variables de las que obtengo el resultado hago otras operaciones, aquí está el código.
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}` } }Entonces, cuando ejecuto esto, solo da el resultado de la última operación realizada