Loops and arrays II (strange)


#1

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


#2

try putting the condition to

i<names.length - 1

or 

var i = 1

#3

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!


#4

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


#5

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


#6

The last line is nonsense.

If you try to console.log an Array type

console.log(nameOfArray);

and you get all entries.

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


#7

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