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

166
Views
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 answers
Answer question

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 Report
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!