Unit 5.1. If/else


I don’t understand what the modulo thing means. I have my if/else statement inside the IS/Even statement, and its coming up wrong. here is my full code:

var isEven = function(number) {
// Your code goes here!
if(4 % 2) {
return true;
} else {
return false;

Can someone please explain what I did wrong, and how I can fix it? thanks! :grinning:


This line:

if(4 % 2) 

4 % 2 will give you the remainder, but you need to check if it is even. How to do this? Well, if the remainder is 0, the number is even. So, suggestion compare the outcome of 4 %2 with 0

Too compare, use two equal signs (or 3 if you want same data type)