Ask coding questions

← Back to all posts
1
Confused on function
rodgerso (0)

Im currently completing a course and would like an answer but please let me write the code. For reference:

// 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'.

So with that my solution:

function sayMyName(myName){
console.log("Hello my name is", myName);
return console.log;
}

let sayPhrase = sayMyName("Josh");

console output: Hello my name is Josh

So i feel like i did this right but im missing something and i can't figure out where i've gone wrong. We have a test checker that spits out: Should return the string 'Hello, my name is ..."
Expected Function to be 'Hello, my name is Josh'.

Can anyone just point me in the right direction where i've gone wrong?

edit: function sayMyName(myName){
let phrase = 'Hello, my name is ' + myName;
return phrase;
}

This is what they were looking for

Commentshotnewtop
3
katyadee (808)

Hey there! You can include a repl, if it's easier. Let me know if you need help with that.

1
ebest (404)

then mark the comment below as the answer.

1
mwilki7 (109)

Did you forget the comma inside the string?

1
rodgerso (0)

@mwilki7 Tried it and unfortunately no, it still gives me the same output.