For Loop prints out every letter of an array


#1

I want this code:

var name = ["Natsu", "Ichigo", "Naruto", "Saitama", "Keichi"];
var i;

for (i = 0; i < name.length; i++) {
console.log(name[i]);
};

to print out the names, but instead it prints out every single letter of the names...
Whats wrong with it?


#2

There is no problem in these lines of code. Try to run it here. You will see that the names are printed on console correctly.

If this is only one part of your code, maybe the problem is elsewhere.


#3

There is a problem with the Code.

name is a reserved word in javascript.

If you try here code in your browser console you will see the result she explained.
Change the varibale name to something else you get the right result.


#4

Replace "name" variable by "names" as per required in exercise.


#5

You are right. It's build-in property.