Could you explain to me like I am five years old following statement? **i % 2 !== 0**

The first part is the modulo or remainder operator. It means â€śwhat is the integer part leftover after doing integer divisionâ€ť so `i % 2`

means the remainder after dividing by 2. For even numbers the remainder after dividing my two is 0. For odd numbers, the remainder after dividing by 2 is 1.

The `!==`

is the â€śnot equal toâ€ť operator. It returns true if the arguments are not equal.

So, putting that together this statement says â€śreturn true if the remainder after dividing i by 2 is not equal to 0â€ť which in other words means â€śreturn true if i is not evenâ€ť (since even numbers would have a remainder of 0) which could be stated even more simply as â€śis i odd?â€ť

Hope that helps. Ask away it you need more clarification.

1 Like