Functions RECAP - Introduction to functions - stuck. Help please


#1

Someone help please. I have no idea what I am doing wrong.

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

it gives me an error Oops, try again. Hmm, it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie. . and the outpput on the right is [Function: nameString]

I tried this as well:

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

But it says Oops, try again. Hmm, it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie. and the output on the right is "Hi, I am name"

Help please.


#2

name is a variable so no need to put it in quotes.


#3

Yes, thats what I thought as well but whenever I omit the quotes I get SyntaxError: Unexpected EOF


#4

Can you put the updated code here ?


#5

I just used this

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

I removed the quotes around name.

BUT there is an error and it says Way to go!. I'm incredibly confused.


#6

Okay we have to pass function with its parameter to the console.log.

Like this..

console.log(functionName(argument));


#7

Like this?


#8

There is a space between Hi, and am.
String should be exact match of what it says in instruction.

and you still put name in quotes?
Its a variable, right?


#9

We figured it out.
Thank you for helping me through it. You're suggestions worked - I removed the quotes from name and put the name in the console.log

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


#10

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