7-when to 'while and when to 'for', not understanding why this isn't working


#1

https://www.codecademy.com/courses/javascript-beginner-en-ASGIv/2/1?curriculum_id=506324b3a7dffd00020bf661

originally i had my own while loop and for loop for this exercise, however as it kept on not working i went back and attempted to copy and past a while loop that worked and a for loop that worked. still doesnt work. before doing so though i compared the syntax to the ones that worked and the ones i was doing- i did not see how my syntax was incorrect so i thought just copy and pasting them should work...well it doesn't. im not sure what exactly is wrong here. the error message reads:"unexpected token)" and was doing so before i copy& pasted my previous text. Any input would be appreciated.


understand=true;
var count= 0;

var loop = function(){
	while(count < 3){
	console.log("I'm looping!");
	count++;	
		understand=false;
		
		}
};
 for  ( var i=2;i < 23; i+++)  {
     console.log(i);
 };

 loop();


#2

for ( var i=2;i < 23; i+++)

you added extra + it should be i++


#3

thank you, jesus christ that was annoying. i was beginning to feel like i was getting high blood pressure. anyways, as stated- very much appreciated!


#4

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