Syntax error! can't debug


#1

I'm on the last part, which is number 11. It is asking me to write one for loop, while loop, and do loop and they all have to be syntactically correct.
This was my answer, however there is a syntax error but I can't seem to find the problem.

var boys = ["ed boi", "soflo", "Joey Salads"];
for (var i = 0; var i < boys.length; i++){
console.log(boys[i]);
};
var x = true;
var k > 5
while(x){
if(k > 5){
console.log("c9 is a good song");
}; else {
console.log("hold up we dem boys");
};
x = false;
};
do {
console.log("are you ready to rumble!!")
}; while(x){
console.log("why not?")
x = false;
};

Thank you for assisting!


#2

Hey @invisiblepop,
please, do the community a favour and use markups :stuck_out_tongue:


You got a few mistakes in your code:

for (var i = 0; i < boys.length; i++) {}

Don't use var again in the second param. of the for-loop


var k > 5

What do you want to express with that?
A variable with a random integer-value bigger than 5? - Doesn't work in this way.
Anyways, always end your declatations with a semicolon ;
Try var k = 6; instead


Uhm... what kind of do-loop should this be?

Just delete the three four lines + the while(x) { ... after };


After correcting those "faults" your code should work.
I hope I could help you :slight_smile:


#3

Thank you! But how do i use markups to help the community!


#4

Just put your code in

``` CODE OVER
MANY LINES```

Will look like:
CODE IN
MANY LINES

` CODE IN A SINGLE LINE `

Will look like:
CODE IN A SINGLE LINE