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

151
Views
How to Add specific values to an array?

I am creating a function which takes in a minimum and max value. The output should list all the even numbers between these two parameters. I have attempted at creating an array to display these numbers but I get this output:

evenNumbers(4,13) returns: undefined evenNumbers(3,10) returns: undefined evenNumbers(8,21) returns: undefined

How to fix my code so it shows the list properly?

var evenNumbers = function(minNumber, maxNumber){
      var list = [];
      for (let i = minNumber; i < maxNumber; i++){
        if (i % 2 == 0){
          for(let k = 0; k < maxNumber; k++){
           i = list[k];
          }
          
        }
      }
      return console.log(list);
    }
    
    console.log('evenNumbers(4,13) returns: ' + evenNumbers(4,13));
    console.log('evenNumbers(3,10) returns: ' + evenNumbers(3,10));
    console.log('evenNumbers(8,21) returns: ' + evenNumbers(8,21));
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!