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

158
Visualizações
I created a function that generates a random number which is contained inside the variable. I run the code on the console yet I get undefined?
function nextSequence() {
    var randomNumber = (Math.floor(Math.random() * 3) + 1);
}

i ran this on the console yet only got undefined i dont know what is wrong with this. any help is appreciated

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you want to use this number outside of the function, you need to return it from the body of the function and then call the function itself:

function nextSequence() {
  return Math.floor(Math.random() * 3) + 1;
}

const num = nextSequence();

console.log(num);

about 4 years ago · Juan Pablo Isaza Relatório
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