11.Review - Lack of understanding


#1

<>


Can someone explain me what is wrong with my code? I have the feeling, that I dont understand how exactly to build a proper working do,while,for function


noClue = 5;
noClue = function(){
    for (i=1; i<5;i++){
         while (noClue < 5{
             do{ console.log("I have no clue what I'm doing!")
            }
        }
    }
};


#2

Here is the basic format I used for my Review Lesson. You can look under the hint for the lesson for examples on for, while, and do as well:

var whatever = function () {
var = whatever;
do {
fill in
} while (2nd var);
2nd var = true
while (2nd var) {
fill in
}
for (var i = 1; i < 11; i++) <----the example given in the hint for this so it can be a little different
{ fill in 
}
}

#3

You're missing a ) after your 5 in the while loop.Replace the { with a ) I think you also have an extra } at the end. And noClue is never under 5 so your while loop won't do anything. If you set it under 5, your loop would crash because there is nothing to tell noClue to increase or decrease to end the loop. You're also trying to set noClue to 5 and a function. Your do and while are also backwards.The way you could code that loop would be:

noClue = 0;
loopFunction = function(){
    for(i = 1; i < 5; i++){
        do{
            console.log("I have no clue what I'm doing!")
            noClue++
        }while(noClue < 5)
    }
}

loopFunction()

#4

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