Functions recap error


#1

Hi all,

So I am currently on lesson 11 on functions in JS, but I can't figure out how to fix my error. It says that I didn't print anything to the console! Here is my code:

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

    nameString("Jeff")

Currently, I just don't know how to fix this, and it would be appreciated if you could help me out.

Thanks!


#2

You use return, and not console.log()


#3

What do you mean by that? I am using return in my function.


#4

And the error says you need to use console.log()


#5

For what though? To call the function?


#6

No, to log "Hi, I am" + " " + name; to the console, rather then return it


#7

Thanks for replying. But when I use console.log in the function, it also gives me an error. Why is this so?


#8

My mistake, return was correct. I hadn't expect the lesson to do this. use console.log() on the function call (last line) and restore your return in your function


#9

It works now. Thanks so much!