8. Functions, return and if/ else

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

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

I can’t solve this, can anyone help? it is saying “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’?”
Thanks

1 Like

Hi try with a number that Can be divide by 3 And 4 when You Call The quarter function

I tried so many numbers, but still it doesn’t work and gives me the same error

…Did You try 12?
If so Can You post your code again?

try with 0 :stuck_out_tongue:

Hey just try the number of 12,

https://discuss.codecademy.com/t/8-functions-return-if-else-calling-the-function/46011

Hey irusaf I had the same problem when I was going through this lesson and I also used 12 as my number but still had problems. I linked the discussion and the moderator who helped me explained it well.

2 Likes

Originally had the same problem. Turns out you HAVE to use the value 12. It’s just what it searches for to allow it as a pass!

1 Like

Originally had the same problem. Turns out you HAVE to use the value 12. It’s just what it searches for to allow it as a pass!

A lie. You don’t have to use 12. You can use many other numbers: …, -120, -108, -96, -84, -72, -60, -48, -36, -24, -12, 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, …


Why 9 does not work?

quarter(9) % 3 === 0 <==>
(9 / 4)    % 3 === 0 <==>
2.25       % 3 === 0 <==>
2.25           === 0 <==>
False

Oh, that’s interesting! Wonder why…does it have to be >9?

No, it can be 0, -12, -24 etc…

It must be the number which after dividing by 4 is divisible by 3. So it must be the number divisible by 3 * 4 = 12.

thank you i got it . I just tried a different number

exemple of modulo %

15%3=0 why? because 15/3=5 the rest = 0.

12/3=4 (the rest = 0) your modulo 12%3=4 .
not 13 % 3 =4.33 the rest is 1,3 .

put a 12 instead of 9

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