Console.log the results of a function - 11/13 - Introduction to Functions in JS


The class is saying this code is right and I can move on to the next lesson but in the display box on the right hand side of the screeen, it is showing


as the results of the console.log instead of "Hi I am..."

Here is my code:

var nameString = function (name) {

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




Actually, I think I may have figured it out.

I need to use:

Instead of:


11/13: Why No Need to Call Function This Time?
Can anyone help me to write the below code? Question about 11/13

By saying this:


You're just printing the type of nameString which we already know is a Function!
You should use this instead:

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


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

I hope it works!


Yes, that works! Thank you mamos98!


You're welcome! :blush:


That's really interesting, Mamos98...thanks...BUT then this raises the question of Code Academy's/Leng Lee's (the lesson author's) competency, as


has been used by them as -- and thus implied to actually be -- the (or at least a) way to call a function and print its output to the console....

NOT HELPFUL, that, as it's turned out!!


What I don't understand is why we don't need to call the function to get it to run...I think that's where the initial confusion lies -- and in my case, still does!! :frowning:


Where has this:


been used? I see your point that the wording might imply that these are two seperate operation. btw @mamos98 showed that you can make it two without a problem. Where it is better written as one. But is there really an exercise where this is used in the way you mentioned it?


I tried it and you need to call the function to get it run otherwise you get an error message. The idea of a function with return is that the value mentioned after return becomes the new value of your function call so e.g.


would have a value of "Hi, I am test". Now it's up to you (the programmer) what to do with this value. If you want to store it in a variable for later use:

var val = nameString("test") ;

or whether you want to use it directly without storing it:



Can you please review this code for me:

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


I getting error message


Probably just a missing space betten , and I


There's nothing wrong with your code...try to test it out -- just be sure to make console.log() an alert() instead to test....


Here is my code

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


This appears correct. My question, why do I get an error saying Oops, try again. Hmm, it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie. The instructions say pass your name, which I did. So who is Susie and why is she trying to mess with my coding? No where do I have a Susie in my code, so why is the code looking for Susie? Susie are you out here? What did you do to the code Susie?


now if I write it like this

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


Susie prints, but still get the same error message. I'm frustrated.


Susie is one of the test cases for this exercise. Don't know if there was an important Susie in the life of the author or if it is just a random name. Anyway I guess your problem is that you have 2 spaces added one after the string and one by + " "+ but one should already be sufficient.


Tenes que usar comillas simples hermano. Estas no " ". Estas si ' '.