for loop into while loop
likeray (0)

help, cannot turn for loop into a while loop.

for works well, just need to make an equivalent while

You are viewing a single comment. View All
mwilki7 (533)

@likeray
On a sandbox, here is my input, and the corresponding output:

var i = 0;
var j = 0;

var count = 5;

for (i = 0; i < count; i++)
{
  console.log("i is: " + i);
}

while (j < count)
{
  console.log("j is: " + j);
  j++;
}

Output:

'i is: 0'
'i is: 1'
'i is: 2'
'i is: 3'
'i is: 4'
'j is: 0'
'j is: 1'
'j is: 2'
'j is: 3'
'j is: 4'