11.Review\*what went wrong*\


#1

var i=1;
var forLoop=function();

for (var i=1; i < 11; i++)
{console.log(i);}
var whileLoop =function();
var whileLoop = true;
{
while (whileLoop<5)
{console.log("Hellow!");i++;
}};

var doLoop=function();{
do
{console.log("I win");}
while(i===1);}

forloop();
whileLoop();
doLoop();

#2

where to start? If you have a function, the start and end of a function are marked by a curly bracket:

var forLoop=function(){
  // function content
};

important: the semi-colon is after the closing curly bracket of the function

the condition of your while loop:

while (whileLoop<5)

is slightly worrying, while function is less then 5? I think you should use a different variable then whileLoop.

your do while loop looks like a infinity loop. i is one, so the condition is always true, the loops keep running for ever


#3

my "whileloop" string is not being printed?
where do e'm wrong

var i=0

var forloop=function()
{
  console.log("ping ping");
    for ( i=1; i < 11; i++)
{
          console.log(i);
console.log('trang trang");
    }
console.log("bluff bluff");};
  
var whileloop=function(){
    console.log("blah blah: " +" +i);
    var i=0;
    while(i<5){
          console.log("whileloop");
        i++;
    }
    console.log(i);
};

#4

console.log('trang trang"); <- a apostrophe doesn't match with a quotation marks

this line:

console.log("blah blah: " +" +i);

the joining of the string and variable is bad. I am sure there are more issues, but without so many issues in your code, i can't keep debugging for you


#5

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