Functions, Return and If/Else


#1

I am doing the code like this,
// Define quarter here.
var quarter = function(number)

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

but every time I press submit, it says, "syntax error: unexpected token if"

Please help!!!


#2

You have to give the function something to do. Code to execute.
Your if statement is looking for a return from the function that isn't there.
Like this:

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


#3

Thank you for your help. I understand it better now!!!
:):):):):):):):):):slight_smile:


#4

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