I do not understand how to call a function what am I doing wrong?


<Below this line, add a link to the EXACT exercise that you are stuck at.>
Function Syntax

<In what way does your code behave incorrectly? Include ALL error messages.>

// On line 11, call the greeting function!
var sayHello (“Jamilia”){ console.log ("Hello + Jamilia);}

Replace this line with your code. 

1 Like

The code in a function is not executed when the function is defined. It is executed when the function is invoked.
Some people use the term “call a function” instead of “invoke a function”.
example 1:

function number(a, b) {
return a * b;
number(10, 2); // Calling the function

number(10,2) means first value(10) will go to first argument(a) and second one(2) to second(b)

To call a function, you simply need to pass the required parameters along with the function name, and if the function returns a value, then you can store the returned value.


var hello = function() {
console.log(“i am saying hello”);
hello();//Calling the function


function hello(thing) {
console.log("Hello " + thing);
hello(“world”)//calling a function

why function?
You can reuse code: Define the code once, and use it many times.
You can use the same code many times with different arguments.
run this roo

function hello(thing) {
console.log("Hello " + thing);
hello(“world”)//calling a function
hello(“sun”)//calling a function
hello(“moon”)//calling a function

Define the code once, and use it many times



@rcodeman Your explanation is clear and helpful, but I have a question about the “function call” section of your answer: Would you be passing “parameters” or “arguments”? Sometimes this can get confusing so I want to confirm I have it down right.

functionName(parameter1, parameter2, parameter3) {
code to be executed

Function parameters are the names listed in the function definition.Function arguments are the real values passed to (and received by) the function.


1 Like

Thanks, @rcodeman. So I’m passing the arguments to the space reserved by the parameters, is that right?

functionName (parameter) {


yes :slight_smile:
think simple
parameters=names listed in the function
arguments= real values



var greeting = function (name) {
console.log(“Great to see you,” + name);
look the codes been typed there.here in the variable name called “greeting” i define a function as function(name) which tells us that the variable "greeting " is now a function and going inside a function there is new as +name that is parameter which is also called the formal parameter. here we call the function “greeting” assigning value akhil which passes to parameter and which will printed via log of console of that statement.

var sayHello=function (name){};

I am having a hard time understanding still can someone please tell me what am I doing wrong?!

function example:

var hello = function() {
console.log(“i am saying hello”);
hello();//Calling the function

and its your function:

var sayHello=function (name){
// code to be executed here
// call the function here


Be sure this text matches exactly what is given in the instructions.

var sayHello=function(){};

var sayHello=function (name){console.log("Hello + There)};

Please post a link to the exercise. Thank you.

Introduction to Function Syntax 3.

A function takes in inputs, does something with them, and produces an output.

Here’s an example of a function:

var sayHello = function(name) {
console.log('Hello ’ + name);
First we declare a function using var, and then give it a name sayHello. The name should begin with a lowercase letter and the convention is to use lowerCamelCase where each word (except the first) begins with a capital letter.
Then we use the function keyword to tell the computer that you are making a function
The code in the parentheses is called a parameter. It’s a placeholder word that we give a specific value when we call the function. Click “Stuck? Get a hint!” for more.
Then write your block of reusable code between { }. Every line of code in this block must end with a ;.
You can run this code by “calling” the function, like this:

Calling this function will print out Hello Emily.

On line 11, call the greeting function and put in a name that you want the greeting function to include.
Press “Save & Submit Code” and see the function get into action! Saves you so much time.

The first thing to do if this is not letting you pass is Reset. Change nothing in the provided code, and only do as instructed.

greeting("Wee Gillis");    // Great to see you, Wee Gillis

yeah i miss one + there… begged my mistake …

Really can not wait for this semester to be over! Then I can focus on phase one and getting into the immersive program. Thanks for all of your help much appreciated.

1 Like

so are you saying that to call a function greeting all I have to do is put

I am so frustrated I am not getting this!!! I am following the instructions to best of my ability and Im still getting error messages now its saying I forgot to call the function now pass it a name. Can someone please help me

Thank you very much Rcodeman. it has worked at last. Good day.

1 Like