Do/while loop #11


#1

so I just completed this section. But I have a question about the variables.

here is the first part of the code I used

var Wil = 0

for (var i= 10; i < 100; i+= 5)
{console.log (i);}

while (Wil < 4)
{console.log ("Wil is the MAN!!");
Wil++;}

I know it is basic. But how would I write a do/while loop here calling on the variable I have already defined, var Wil=0

i tried but I can't seem to figure out how to make it false in the end so that it stops running.

To complete the section I simply created a new variable to use in my do/while loop.

Thanks


#2

If you're talking about making a do / while loop, you mean:

do
//insert code here
while(condition);

Correct?

Because otherwise your code looks like it should work with the "while" loop that you're using.


#3

Hi @wilcarter

@lolman your answer is nearly good, you have to add something else :

do{
//insert code here
}while(condition);

Hold on :wink:


#4

Right, I was thinking of Ruby, good catch!