Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

272
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda