To learn it,you gotta 'do' it yourself


#1

please help: Oops, try again. There was a problem with your syntax.

var x = false;
var getToDaChoppa = function(){
// Write your do/while loop here!

do {
console.log("goog to go");
} while (x);{
x = true;
}

getToDaChoppa();

Replace this line with your code.


#2

do while loop:

do {
  console.log(" do something");
} while (condition)

while loop:

while(condition){
  console.log(" do something");
}

you can't combine the while(condition) of a do while loop to get a do while loop and while loop at the same time


#3

please i dont seems to get, thanks in anticipation


#4

you made your do while loop into a do while while loop, you can't do this. It is like taking an apple and pear, cut them in half and try to glue half the apple and half the pear together, it doesn't work


#5

thanks alot, really appreciate it, i just got it. your analogy of the apple and pear thing worked. Cheers!.
var x = false;
var getToDaChoppa = function(){
do {
console.log("good to go");
} while (x = false);
x=true;
}


#6

you're welcome

i do however have to correct you again:

 while (x = false);

a single equal signs means set a variable to a certain value. if you want to check something is equal (for example to check if a pear equals an apple) in programming, you need to use two equal signs.

then make sure you place this line:

x=true;

inside the loop:

do {
console.log("good to go");
x = true;
} while (x == false);

otherwise, you get yourself an infinity loop


#7

Could somebody help me? Here is my code:

var soloLoop = function(){
while(myCondition) {
console.log("Looped once!");
myCondition = false;
};
soloLoop();

By the way, I am on 6. Solo flight.


#8

your function:

var soloLoop = function(){

the { of your function has no matching }

and you don't define myCondition bfore your while loop


#9

Thanks! :smiley: :grinning:


#10

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