Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Review Creating Reusable Code with Functions

Arvind Kevin Arjun Sharma
Arvind Kevin Arjun Sharma
8,272 Points

Help me please!!!!!!

Idk what to place there...

function warning() { alert('Warning, warning, warning!'); }


and here...

function greeting( name ) { var message = "Hello " + name;



3 Answers

So I just retook this quiz again; first one is looking for you to call the function, second is looking for you to return a value. I'd review how to invoke a function and the basic structure of writing a function to return a value, I believe it's in the video prior to this quiz. Best of luck!

To call a function you use the function name and then parenthesis so that being said if i create a function:

function kamal() {

alert("hello hows it going");


How would I call that function ?

But as James suggested I would go back and do the course to get an understanding

Hi, Arvind Arjun Sharma:

There's several ways to call a function in JavaScript, but the most common wayβ€”as some have pointed outβ€”is to use a set of parenthesis () that is recognized by JavaScript parsers, engines tokenizers to be an intent to run a function (doing their parts accordingly).

If I have a function identified with the name foo (or associated with a variable identifier of foo) either via

// Function declaration
function foo() {
  console.log("I'm to be called:");


let foo = function(){
  console.log("I'm to be called:");

In order for the statements inside the function to be ran (in this case just console.log("I'm to be called"), I can run merely foo().

If defined parameters for declared for a function such as the name variable in the second example you provided, a value can be provided as an argument when you attempt to invoke the function like greetings("Kevin").

Other ways to invoke a function: call & apply

If you're curious, the other ways of invoking or calling a function is to call or apply. The first argument of either enables you to change what the value of this is.

After that the behavior of both change in very important ways. apply allows you to pass an array of parameters, while call enables you to add an infinite amount of arguments that are handled for you.

When using apply, greetings can be called greetings.apply(null, ['Kevin']); when using call, greetings can be called like greetings.call(null, 'Kevin'). null is used to make this inside the function's body (where the code specifically for the function is written) be null for demonstrative purposes.

These alternate ways of calling a function are especially useful when you have functions that accepts other functions as arguments towards calling it or returns other functions. These sort of functions are usually called high-order functions.

They're also useful when you want to call functions just-in-time with very specific, non-obvious values for this and the other arguments the function accepts.

I hope this helps!