Functions, return if/else


#1

I don't know what to do with this code:

// Define quarter here.

if (quarter() % 3 === 0 ) {
console.log("The statement is true");
} else {
console.log("The statement is false");
}

Here are the instructions:
Define a function called quarter which has a parameter called number.
02. This function returns a value equal to one quarter of the parameter. (i.e. number / 4;)
03. Call the function inside the if statement's condition (and put in a parameter value!) such that "The statement is true" is printed to the console.


#2

To define a function called quarter has one parameter called (number) you must write:

var quarter = function (number) {
    return number / 4;
};

before you call it inside the if statement's condition.


#3

ok i'll try that :grin:


#4

thank you for your help


#5

you're welcome :smiley:


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.