12. loops and arrays II


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-NhsaT/2/4?curriculum_id=506324b3a7dffd00020bf661#


i dont know why but it leaves the error message 'Your code should have printed 'I know someone called ellie' but it didn't. Make sure you put the 'i know someone part exactly right, and dont forget the space between the phrase and the line!' thanks


// Click on "Stuck? Get a hint!" if you get stuck!
var names = ['ellie', 'thea', 'tavie', 'beth', 'sabri']
for (var i = 0; i < names.length; i++) {
    console.log("I know someone called " + name[i]);
}


#2

You are missing a semi colon after your 'sabri'] Other than that everything else looks fine atleast compared to my answer


#3

tried that... it says unexpected token...
// Click on "Stuck? Get a hint!" if you get stuck!
var names = ['ellie', 'thea', 'tavie', 'beth', 'sabri';]
for (var i = 0; i < names.length; i++) {
console.log("I know someone called " + name[i]);
}


#4

so your spacing is off as well and also the semi colon goes outside the ] not inside I ran this code below through and it works with the new spacing and semi colon addition

var names = ['ellie', 'thea', 'tavie', 'beth', 'sabri'];
for (var i = 0; i < names.length; i++) {
console.log("I know someone called " + names[i]);
}
If this works just hit the solution button and I hope this helps :smiley:


#5

thanks! works fine now!


#6

Great! Glad to help!


#7

var names = ['Ram','Shyam','Jadu','Madhu','Sadhu'];
for(var i=0;i<name.length;i++)
{
    console.log("I know someone called Ram "+ names[i]);
}

Getting the same above error...what is the prob


#8

I think your code now wirtes "I know someone called Ram Ram"
try:
var names = ['Ram','Shyam','Jadu','Madhu','Sadhu'];
for(var i=0;i{
console.log("I know someone called "+ names[i]);
}


#9

just try this guys var names = ['Billy', 'Billy', 'Billy', '#Billy', 'JOHNCENA'];
for (var i = 0; i < names.length; i++) {
console.log("I know someone called " + names[i]);
}


#10

Yeah like @wilhelminapepermunt said I believe that your problem is you put Ram in your I know someone called statement when Ram is not needed in it Other than that your grammar and all looks fine so that should work


#11

Thanks everyone.Got the mistake...A silly one:sweat:


#12

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