Oops, try again. Your code should have printed 'I know someone called Peter', 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 am failing to separate "called" and names[i] yet i put a space.therefor I am getting an error.

var names = ["Peter", "John", "Rogers", "Andrea", "Patrick"];
for (i = 0; i < names.length; i++) {
    console.log(" I know someone called" +  names[i]);


Well you need to put the space at the end of the string not on the beginning. And to add a space you have basically two options, maybe even 3:

"My string "+value //just a space inside of the string
"My string" + " " + value // a space concatenated to the string

console.log("My string",value)

because console.log prints its parameters (separated by comma) with a space in between. But this only works for console.log the other two should work always.


@haxor789,thanks very much.I used method 2 and 3 for adding spaces.Method one didn't work for me or dare I say ,i didn't understand the way to add the space.


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