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

94
Visualizações
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 Respostas
Responde à pergunta

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