Java Script - 8. Functions, return and if / else


#1

I need some help with this code:

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

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


#2

Just remove the semi-colon...

I prevent that error by writing the opening brace on the same line...

var foo = function () {

};

#3

Can someone help me?
Thanks in advance

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

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


#4

Your code is correct. What error message you have?


#5

Oops, try again. Did you remember to call quarter() inside the if statement with a value that would cause it to print 'The statement is true'?


#6

Your result should be true, but you have false.


#7

20 is divisible by 4, but 5 is not divisible by 3.

Think Least Common Multiple (LCM).

3 * 4 == 12

This suggests that any multiple of 12 will be divisible by both 4 and 3.


#8

A post was split to a new topic: I’m stuck could you help me please!


#10