I need help with Homework problem

// Exercise Three:
// Create a function called ‘sayMyName’. It will take one parameter. Call this
// parameter ‘myName’. Return the phrase "Hello, my name is " and the myName parameter.
// eg: if name is ‘Dan’ it should return the string: ‘Hello, my name is Dan’.

myName = ‘Dan’;
function sayMyName (myName){
return “Hello, my name is (myName)” ;

So you need to set a variable that is equal to what you type in. Then set the return statement to return "hello my name is “variable”
Good luck!

1 Like

you mean put the variable inside the function?

You’re putting myName in the string, so it will say, literally, Hello, my name is myName. Instead, put it outside the quote like this:
return “Hello, my name is" + (myName) ;

1 Like

ohhh so it need s +?

Declare the variable outside the function, then call the var inside the function.
x = 1
function() {
“X is equal to” x

1 Like

No. Put myName outside the quotes and then put a + between these two. Also don’t put the parentheses it was a typo.

1 Like

ok so this is what I got…

myName = Dan;
function sayMyName (myName){
return "Hello, my name is " + myName;

its saying it correct, however its showing many errors, its wont show it.

Put quotes around “Dan” because it is quote and not variable.


Ight thx man that helped alot

I gotcha. Have a nice day!

1 Like