Help with function


#1

I don't get the following:
Write a function called nameString()
It should take name as a parameter.
The function returns a string equal to "Hi, I am" + " " + name.
Call nameString() by passing it your name, and use console.log to print the output.

var nameString = function (name) {

return nameString "Hi, I am" + " " + name;
console.log (nameString);
};
name("Gabriel")

The error I get:
Your code doesn't look quite right. Click "Stuck? Get a hint!" if you need help!


#2

what is the name of the function you're calling? name or nameString? are you using console.log to print the function to the console?


#3

The function has to be called nameString, with name as the parameter.
So I wrote:
var nameString = function (name) {

I wrote for the second part in the exercise:
return nameString "Hi, I am" + " " + name; from the hint.

And then I got stuck with the last step.
I wrote:
name("Gabriel"), so that it print outs my name.
But I'm uncertain about how to write the console.log in this case, and what I'm doing wrong.


#4

here, you are writing name to print out your name but your function is called... ?


#5

Instead of calling the function perimeter replace it with the function name that is

nameString("Gabriel");


#6

And the second thing is : Why you are using console.log? they said to return it. Use

return

COde:

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


#7

The interpreter says you should check the hint. I think you should.

However, it says to this:

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

greeting("Gabriel!"); //this is where you call your name on the greeting function that was created.

#8

The hint only says":
The code block in the function should look like:

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

Just a reminder: we need to add " " to the string so we have a space between the word 'am' and the word 'name.
So I didn't really help me at all.

Why: return "Hi, I am" + " " + name;
And not: return nameString "Hi, I am" + " " + name;


#9

In case you missed it (it was on a lower-level reply, not a parent comment), you need to add console.log on the line where you call the function:

console.log (nameString("Gabriel"))

because it says to use console.log to print the output of calling nameString with your name


#10

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