Javascript 12 Loops and Arrays II "something COOL"


#1

i use this code

var names = ["Jhon", "paul", "ringo", "george", "pete"]

for(e in names){
console.log("I know someone called "+names[e])
}

and the "test" logic came out


#2

Yes it works..because in is a javascript operator like for and if. It looks for the variable and set it equal to the name that you mentioned like e in your code..its a magic of javascript.!!! Happy coding!!! :slightly_smiling:


#3

What is the problem with this one? Maybe add a var before your "e" variable.