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