Functions Recap #11


I cannot get away from the syntax error.

Identifier expected

Replace this line with your code. 
var nameString = function (name) {
return "Hi,I am"+" "name;

console.log ("Shannon");


If you use the so-called concatenation
you do that by using the plus-sign-+

return "Hi,I am"+" "+name;

where you should use the EXACT string output as is asked for in the Instructions !!!!


Hi @wndrwn,

var nameString = function (name) {    	
    return "Hi,I am" + " " name;
    console.log ("Shannon");

I've added some space to your code. Can you see where the problem is now? Hint: what are you returning?

Some other notes:

  • Once you return the program escapes the function, i.e. the lines below return will not be executed.
  • You need to call the function for it to run.

Hopefully these pointers help you, but please let me know if you have further questions.



var nameString = function (name) {
return "Hi, I am"+" "+name;

console.log (nameString);

nameString ("Shannon");

This prints fine now but it says I didn't print anything to the console



Please refer to my first bullet point: the lines below return [in the function] will not be executed.
Does that give you an idea? If you still need help can you please share a link to the exercise?


PS: You can also write your string as: "Hi, I am " + name if you like.


Thanks! I got it!!! Sometimes I can't see the forest for the trees


Glad to hear it! No worries, happens to me too :slight_smile:


its not working please can you write the answare


@datarunner71858 Hi Raslan,

If you can't figure it out I suggest you post a new topic with your code and what you are having trouble with. CodeCademy has a really easy template for new posts you can follow! :nerd:


Mine worked but it kept printing "[Function]" before "Hi, I am..."
How do I get rid of "[Function]"?


@mikaelamula Depends on what your code looks like... (*coughs*)



If you have an error create a +New Topic with code, lesson and error :slight_smile: