I'm really stuck and I can't see whats wrong


#1

var count=0;

var loop = function(count < 3){
while(){
//Your code goes here!
console.log ("im looping");
count++;
}
};

loop();
this is my code


#2

In what way does it not behave like you want? Describe the problem. Explain why you are stuck, what information do you need to solve it yourself?


#3

It says unexpected token < under syntax error


#4

Well you don't have a whole lot of >'s so that tells you where to look.
Consider what you were trying to accomplish with that code, is there somewhere that you can look up how to do that thing? (Previous examples in the exercises, or google, google is very useful.)

A tip for getting more useful error messages is to run the code in your browser (firefox shift+f4 to bring up scratchpad) or at repl.it (the node.js environment might have better error messages that the javascript one)

In this case though, it's said all it can.


#5

Doesn't look like there's a condition inside of the while(). For a while loop to execute, you need to have some kind of condition (maybe count < 3 in the while loop instead of the function?)


#6

i'll try that now and see if it works


#7

Now it says unexpected token while


#8

Perhaps you left the previous line unfinished, so that it expects something else first.


#9

var count=0;

var loop = function (console.log ("I'm looping"); )
while(count < 3){
//Your code goes here!
count++;
}
};

loop();
This is what it currently is and from what I can see there is nothing left open


#10

put the console.log back into the while loop and it should be okay. You aren't actually passing anything to this function, so the parenthesis for the function should be empty. What the while loop should do is print "I'm looping" to the console a few times until the condition isn't true. By putting a statement with a semicolon in a function's parameters, you'll get an error.

Edit: also you need an opening brace again at the end of the line for the loop function


#11

Should it look like this
var count=0

var loop = function ()
while(count < 3 console.log("I'm looping")){
//Your code goes here!
count++;
}
};

{loop}(count++; );


#12

I should've made it a little more clear, the console.log statement needs to go in the body of the while loop. The stuff in the while loop's parenthesis just check to see if the loop should be repeated. So while(count < 3), the loop will execute until the condition is no longer true (when count >= 3 it will stop automatically). You want the console.log to execute every time the loop is repeated, so it goes where "//Your code goes here!" is.

There shouldn't be anything in your function's parenthesis or the place where you call it ( loop() ). You only put variables in parenthesis when you need a value that isn't available to it anywhere else. Since count is declared globally (outside of all functions), it can be accessed anywhere. Let me know if that stuff makes sense.