Why doesn't my for loop get printed to the console?


#1

I tried to print out "jup" five times using a while loop and "nope" five times using a for loop.
Only the while loop gets printed to the console and I was wondering why.
Here is my code:

var i = 0;

while (i < 5)
{
console.log("jup");
i++;
}


for (var j = 10; j <= 5; j--)
{
if (j > 5)
{ console.log("nope") }
}


11. Review What is wrong with my code? Console does not log for loop
#2

Hi inside your for loop try to add a console.log like that

for (var j = 10; j <= 5; j--)
{
console.log(j)

if (j > 5) 
{ console.log("nope") }
}

#3

I tried this, but I still only get 5 times "jup" on the console. I even copy-pasted your code to make sure I didn't miss anything.


#4

Try it like that

for (var j = 10; j <= 5; j--)
{

if (j > 5) 
{ console.log("nope") }
else 
{ console.log(j)}
}

#5

Still nothing...
But thanks for trying to help me anyway.


#6

If you just want to print out "nope" five times using for loops,

for (var j = 10; j > 5 ; j--) {

console.log("nope");

}

isn't this what you wanted?? just guessing..