Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
Storing the value of a variable after using a funcition

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!