I learn loops in JavaScript with for-loop and I have this code (j) that does not work with me I don’t know why?
let start = 1;
let end = 6;
let breaker = 2;
for (let i = start; i <= end; i ) {
console.log(i);
for (let j = breaker; j <= end; i ) {
console.log(j);
}
}
CodePudding user response:
You never increase j
thus you get endless loop, try replacing
for(let j = breaker; j <= end; i )
using
for(let j = breaker; j <= end; j =1)
CodePudding user response:
You changed i
and j
in inner loop
let start = 1;
let end = 6;
let breaker = 2;
for (let i = start; i <= end; i )
{
console.log("i => ", i);
for(let j = breaker; j <= end; j )
{
console.log("j => ", j);
}
}
`