Review Troubles


#1

I'm having some troubles. Says SyntaxError: invalid increment operand. Help please.

for (var i=0; i <= 34; 1++) {
    console.log(i);
    }

var gameBoy = true;
while(gameBoy) {
    console.log("Let's Play!")
    gameboy = false;
    }

var DS = Amigo;
do {
    DS++;
    console.log("Rapido!" + DS +"!");
} while(DS);


#2

Make 1++ to i++ in your first for loop statement. You need to increment your index, not an integer.
Also, I don't think you can or need to increment your DS in your do function as it will create an infinite loop.

Make sure you spell gameBoy correclty in you function to avoid infinite loops!

for (var i=0; i <= 34; 1++) { //<= !wrong increment
    console.log(i);
    }

var gameBoy = true;
while(gameBoy) {
    console.log("Let's Play!")
    gameboy = false; //<= !infinite loop cause
    }

var DS = Amigo; //<=! make it equal to false: var DS = false
do {
    DS++; //<= !infinite loop cause
    console.log("Rapido!" + DS +"!");
} while(DS);

#3

first sql first line goes ok or right 2nd line have showed error.


#4

Hey i was able to plug it in and it worked except for it told me that Amigo is not defined. I though by using var DS = Amigo i would be recognized? How do i fix this or what should i us for var DS = ?


#5

Oh, you need to assign DS the value of false. var DS = false. It is because in the do function, you need a boolean value for your while loop to proc. A while loop can't proc some random variable that is not of a boolean value.


#6

Hey so i changed var DS = false and now my browser keeps crashing.

for (var i=0; i <= 34; i++) {
console.log(i);
}

var gameBoy = true;
while(gameBoy) {
console.log("Let's Play!")
gameBoy = false;
}

var DS = false;

do {
DS++;
console.log("Rapido!" + DS +"!");
} while(DS);


#7

As I have stated in the first comment I've made. DS++ causes an infinite loop. Remove it and your browser won't crash.


#8

Oh, i missed that. Thank you so much!


#9

You're welcome! Have a nice day :slight_smile:


#10

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