Loops and arrays II (strange)


This code is correct, but why on last line print just name


try putting the condition to

i<names.length - 1


var i = 1


Code does not work, writes in both cases: :smirk:

Your code should have printed 'I know someone called "Jake or Yulia"', 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!


then remove the last line

here is your code..its working ...i checked

var names = ["jake", "helena", "tommy", "rez", "yulia"]
for (var i =0; i<names.length; i++)
    console.log("I know someone called " +names[i]);

you don't need the last line...the var i already holds the value during each loop..as the length is 5 so it will hold the value 5 times and display it in the console. That's what we need


You're right - the last line does not need, Thank you!


The last line is nonsense.

If you try to console.log an Array type


and you get all entries.

In this case like @abhi.borkakoty told you it is not necessary


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.