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

98
Views
I have a problem with the iteration loop javascript

I have a problem with the repetition of an error. I need to display the hours at 18, 19, 20, 21, 22 with the minutes, but there is a repetition at 18

let CloseTime = 23;
let TheTimeNow = 20;

let mintes = 20;
let LastMinutes = 60;

let resultMintes = [];
let lastResult = [];

for (TheTimeNow; TheTimeNow <= CloseTime; TheTimeNow++) {
  for (mintes; mintes <= LastMinutes; mintes += 5) {
    resultMintes.push(`${TheTimeNow}:${mintes}`);
  }

  lastResult.push(resultMintes);
}

console.log(lastResult);

https://codesandbox.io/s/staging-glade-e2msc?file=/src/App.js

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

0

thats the problem with the inner loop, in the first iteration of outer loop, the value of minutes stays at 60, so the inner loop end immediately in the following iteration, what you need is probably for (mintes = 20; mintes <= LastMinutes; mintes += 5) re-initialize your mintes (you got a u missing but this just spelling not big deal) so the inner loop can restart in every iteration of outer loop

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!