8 Functions if/else Confusion!


#1

Here is my code for this one.

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

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

It reads that that statement is true just as it requires. but it gives me the following error.

"Ops, tente outra vez. Hmm, it looks like your quarter function doesn't return -25 for -100."

I'm not sure what this means as there is nothing about these numbers in the instructions. please help!


#2

Your function should return one quarter of whatever number is passed into it.

    return number / 4;

Now in the statement we will pass a number literal to the quarter() function in the call expression argument:

if (quarter(12) % 3 === 0) {

Any number divisible by 12 will yield a true result. 12 is the LCM of 3 and 4.


#3

yes, this makes sense. Thank you!


#6

A post was split to a new topic: Unexpected token: return