Why am I still getting a loop?


#1


I've been trying to figure it out for the last hour and everything looks closed from what I can tell. What is it that I'm missing?


var loop = true;

do {
    console.log("Show me what you got!");
}

while(loop = true) {
    console.log("I like what I see!");
    loop = false;
}

for (var check = 1; check < 5; check++) {
    console.log(check);
}.


#2

Syntax:

do {
    code block to be executed
}
while (condition);  // you missed it

how many times it'll loop?


second

while(loop = true)  //you have to check here.= means assingment so use == or ===

while(loop == true) or while(loop === true) or while(loop)


and here

for (var check = 1; check < 5; check++) {
    console.log(check);
}.  //remove . maybe typo

#3

Thanks man!

The = was fine but I wasn't closing my do with a false statement. I was running it into a another why loop but never closed it out.


#4

what do you mean by The = was fine?


#5

I kept the = as a single and it worked.

When I changed it to == it was giving me an error.


#6

can you please give me your updated full code?


#7

No problem. Here is the code I ended up with and it went through.

var loopTwo = false;
do {
    console.log("Show me what you got!");
} while(loopTwo);
    
var loop = 5;
while(loop < 10) {
    console.log("I like what I see!");
    loop = 15;
}

for (var check = 1; check < 5; check++) {
    console.log(check);
}

#8

now your code is fine.

i was telling you cant use = that is here

while(loop = 10)

it'll not work and you are not using it. you are using

while(loop < 10)

it's too fine. you told me The = was fine so i m asking you :slight_smile: it's ok. happy coding :slight_smile:


#9

Ahhhh I get what you meant now by assignment.

I probably should go to bed instead of trying to code this stuff so late...


#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.