12/15 .length-based end question


#1

12/15 .length-based end question


#2

What is your question?


#3

Always I am getting the same error for every code.Please help me.Is something wrong with the code

var names=["Ajay","Shiva","John","Martin","harsha"];
for(var i=0;i<=names.length;i ++){
console.log("I know someone called " +names[i] );
}
Oops, try again.
Your code should have printed 'I know someone called Ali', but
didn't. Make sure to type the 'I know someone called ' part exactly
right, and don't forget the space between that phrase and the name!


#4

Maybe there is a space to much between i and ++. Also <= is not a good choice if you count from 0 to name.length you have name.length+1 loops (count them by hand if you don't belief me) and therefor the last one will result in an undefined array index.