12.Loops and Arrays II


#1

Could anyone help me with this code error?

var names ["John", "Isabell", "Gregory", "Nick"];
for (var i = 0; i < names.length; i++) {
    console.log("I know someone called"+" "+ names[i]);
}

Oops, try again. There was a problem with your syntax.


#2

Missing = between names and the value (array) you want to assign to it.


#3

Are you still having a problem with this? It should look like this (Click to see):

Click me!

var names =  ["John", "Isabell", "Gregory", "Nick"];
for (var i = 0; i < names.length; i++) {
    console.log("I know someone called"+" "+ names[i]);
}


#5

var names = ["Igor", "Ana", "Matek", "Rada", "Marko"];
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 Igor', 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!

I'm confused?!


#6

Works fine for me, try using another browser as a workaround.


#7

@dzejolina Add a single space in-between the empty quotation marks.
So instead of:
console.log("I know someone called " +""+names[i]);
try:
console.log("I know someone called"+" "+names[i]);
Hope this helps!


#8

here you have to give press space bar at the end of "I know someone called ".
I have provided spaced between called and " .

answer looks like this

var names = ["Kane","Goodwin","Cambel","Martin","Icson"];
for (var i = 0;i < 5; i++ )
{
console.log("I know someone called "+""+ names[i] );
}


#9

you dont need to put the plus sign twice. Try to only put one instead and leave a space between "called" and the ending quote sign.


#10

Please don't revive old topics, thanks.


#11

oh, I'm so sorry! I didn't saw the date first :stuck_out_tongue: my bad!