10.To learn it, you gotta 'do' it


#1



What should I do ?


var getToDaChoppa = function()
{ 
var number = 15 // Write your do/while loop here!
do { console.log("I like this number " + number); }
};
while (number === 15);
getToDaChoppa();


#2

@methodsolver33159

You forgot to close your getToDaChoppa function after this line


#3

Do it like this ?

var getToDaChoppa = function()
{
var number = 15 // Write your do/while loop here!
do { console.log("I like this number " + number); }
while (number === 15);
};
getToDaChoppa();


#4

@methodsolver33159

Yeah, it should work like that.


#5

I just tried, it didn't work :frowning:
Besides, it said I Syntax error : Unexpected token }


#6

@methodsolver33159

I think this is because it will generate an infinite loop. In your while loop after your do

Set a condition that is going to be evaluated to false so that the loop stops running.


#7

Still have SyntaxError : Unexpected token }


#8

@methodsolver33159

Remove this line

{ number === 2 };

I mean, setting the condition in between the parentheses () for your while loop. Here

while(/* The condition evaluated as false here */);

#9

Thank you :blush:


#10

This isn't working for me.

var getToDaChoppa = function()
{
var number = 13
do ( console.log("My favorite number is " + number));
};
while(number === 13);
getToDaChoppa();

It says "Unexpected Token"


#11

Can you please help me here? Do I miss something?

var ch=true;
var getToDaChoppa = function(){
do {
console.log("I'm looping");
}
while (ch) ;
};

getToDaChoppa();


#12

do-while loop through a block of code once, and then repeats the loop while a specified condition is true. So, in your case we have infinite loop. You need to change var ch=true; to false, so now your loop knows when it should be stopped.


#13

I solved. Thank you!!
var ch=true;
var getToDaChoppa = function(){
do {
console.log("I'm looping");
ch=false;
}
while (ch);
};

getToDaChoppa();