Help 12. Loops and Arrays ||


#1

I cant seem to get this code to work.

names ["Cheese", "Big",  "Head", "Food" , "What"];
for (var i = 0; i < names.length; i ++) {
    console.log("I know someone called "+ " " + names[i]);
}

The outcome says

 "Oops, try again. Your code doesn't look quite right.
Click on "Stuck? Get a hint!" if you need help!"

#2

names ["Cheese", "Big", "Head", "Food" , "What"]; should be names = ["Cheese", "Big", "Head", "Food" , "What"]; to assign names as array.


#3

]

you are missing an = after names.

names = then your array. should work after that


#4

and the i ++ should be like that i++ also your conosle.log should be like that
console.log("I know someone called " + names[i]);


#5

oh yeah, lol I totally forgot about the equal sign.


#6

I dont think spacing really matters with javascript.


#7

I got it, it was just the equal sign and another issue i will not disclose on here.


#8

Haha why not? Maybe someone else will have the same problem and we can discuss. We are here to learn and help each other learn in the end. I'm sure it's not a big deal.

And what @wizmarco wrote, you could have optimized spaces in your console.log() but it's not a big deal. Space between i and ++ didn't matter, but still try to keep them together.


#10

What are you talking about?


#11

The amount of people on here that don't print out their corrected syntax is too damn high...


#12

Well, I can understand that people think their code is bad and that someone will make fun of them. But we're all here to learn new things and practices ones we already know, so whenever in doubt, one should share his code, no matter how ugly it is. It's easier to help that way and maybe good advice about writing better code will actually make people think before then put something to paper (on the screen in this case).