-1

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);
  }
}

2 Answers 2

1

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)
Sign up to request clarification or add additional context in comments.

Comments

1

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);
    }
}

`

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.