Help 5/11


#1

I don't know what is wrong, this is my code:

//Remember to set your condition outside the loop!

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

loop();


#2

Seems to be quite good so far but unless you give count an initial value e.g. var count = 0; outside of the function it is impossible to determine what count or count++ is. Ok it is it's undefined and NaN but it's clear what I want to say is it?


#3

var count = 0; // you need to declare a "count" variable at the start.

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

loop();


#4

I was able to get the solution by using the tip, however what does this do????

var loop = function(){

Why is it part of the while loop?

Thank you :smile:


#5

It's just a function. You should recognize it from lesson 3. Actually I could only guess why it is there, but it is not necessary for the loop. On the otherhand for some loops it would be interesting to see it run twice. For example if you add another loop() at the end of @bravo_anuj's code you would see nothing because count was declared outside of the function and there for it was set to 3 by the first function call and therefor the second function call is not able to loop again.


#6

I've done EVERYTHING it wants and am STILL getting an error message...Here is my code below:

//Remember to set your condition outside the loop!
var count = 0;

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

loop();


#7

you can help me. I'm stuck in this lesson.

  1. Declare your variables

#8

This did the trick for sure!


#9

try instead of:

while(count.length < 3) {

using:

while(count < 3){

Right now it seems like your code would loop until it got to the third digit (100). That's a lot of looping. But I'm not even certain that it'd work because you're trying to get the length of a integer.


#10

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


#11

hi friends how are you?
dear friends i am struck in this lesson so please help me.
it's lesson: ( 7. Putting It All Together, Part I )
in php.


#12

I think you posted your question in the wrong thread. Personally I know nothing about PHP, and I am unable to help. Sorry!


#13

I also constantly get the same error.

"Oops, try again. Hey now--only one console.log() call!"

var count=0

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

Can anyone help?


#14

use ! at the end of "looping"


#15

Mine keeps saying count not defined


#16

I read the entire thread and I am able to print console.log three times but it still says "not printing the right string"
What is wrong with this code?

var count=0;

var loop=function(){
while(count<3){
console.log("I'm Looping!");
count++;
}
};

loop();


#17

Maybe looping written with a lowercase "l" the rest seems perfectly fine and if you understood what you wrote there you could pass on.


#18

Couldn't get your code to work, try my code it's fine

//Remember to set your condition outside the loop!
var count = 0;
var loop = function(){
while(count <3) {
console.log("I'm looping!");
count++;
}
};

loop();

:wink:


#19

@tyzthijs maybe perhaps you forgot the exclamation mark after "I'm looping!" It can be pretty picky about that.


#20

You posted in the wrong thread, try going to PHP and post there.