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

212
Views
create a range of years without using the range method

Is there another way to produce this array with code that does not use the range method?

Here is and example of what im looking for but using the range method.

const years = range(1990, getYear(new Date()) + 1, 1);

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Yes you can achieve this by writing your own function

    const generateDates = (startYear) => {
        let currentYear = new Date().getFullYear(), years = [];
        startYear = startYear || 1980;  
        while ( startYear <= currentYear ) {
            years.push(startYear++);
        }   
        return years;
    }
    
    console.log( generateDates(2019-20));

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!