8. when to while and when to for problem


I am having some trouble trying to print out the 'for' side
Im only able to get the first part to print out
var i = 1;
var loop = function (){
while (i < 2) {
console.log ("hello");
count += 1;
} }
loop ();

for (var j = i + 1; j < 3; i++) {


@lightattheend I believe your issue is because you already declared "i" as a variable and are trying to add it to one when saying what "j" is. Now I am not sure if this is the issue but try to change your for loop to

for(var j = 0; j < 6; j++)

The other place that might be incorrect is you declared j as the variable in your for statement but are adding 1 to i not j, another solution may be

for(var j = i + 1; j < 3; j++)

Either of these may be the solution, try both to see if they work.


I tried both and they did not fix it =P


@lightattheend may you tell me the error message that pops up so I may know a more precise field to observe?


found the problem loop (); was causing it


@lightattheend I am glad you found the answer to your own problem! :smiley:


i have been stuck on this problem for a week trying to find the problem i asked friends and they didn't know ._.


whats wrong with the loop();
could you help me please


@datajumper36640 take out the loop(); then it should work fine.