Help 12. Loops and Arrays ||


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!"


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



you are missing an = after names.

names = then your array. should work after that


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


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


I dont think spacing really matters with javascript.


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


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.


What are you talking about?


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


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).