Help with Intro to Functions Code Lesson 1


Who else has had a problem with the first exercise of Intro to Functions? I have my code the same as the example with the name Jimbo instead of name. What should my code look like in order for it to make my answer acceptable. I am stuck on this :frowning:

var sayHello = function (Jimbo) {console.log ("Hey, what's up?" + " " + name);};

this is the code I wrote, which mirrors the example except I have Jimbo as the function name, it will not accept my function code, keeps saying I have not called the greeting function. Pass it a name.

Who can help tell me what I'm doing wrong?


your code is a littlebit wrong:

var sayHello = function (Jimbo) {console.log ("Hey, what's up?" + " " + name);};

We declare a variable and with function we say this is a function

var sayHello = function(){


Than we look what would we do with this function. In this case we wanna log a sentence
with our name

var sayHello = function(){
    console.log ("Hey, what's up?" + " " + name);

But which value has name ?
In this case name is a parameter and we get the value via a parameter in the parentheses

var sayHello = function(name){
console.log ("Hey, what's up?" + " " + name);

And now we call the function with a parameter


So we get the result:

Hey, what's up? Jimbo

Does that helped?


I found out my problem lol..I was actually going ahead of the lesson. All they wanted me to do was call the function of the given example code lol..I was writing a fully functional code, which the lesson was not ready for me to do yet, so though my code was right, they wouldn't acknowledge it because i had not called the function from their example. Being too fast for my own good!


Very smart you are! Could you be my mentor?