8. Functions, return and if/ else


#1

// 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


#2

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


#3

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


#4

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


#5

try with 0 :stuck_out_tongue:


#6

Hey just try the number of 12,


#7

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.


#8

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!


#9

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

#10

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


#11

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.


#12

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


#13

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 .


#14

put a 12 instead of 9


#15

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