r/ProgrammerAnimemes • • Nov 19 '23

Improper Code Scoping

Post image
498 Upvotes

18 comments sorted by

View all comments

Show parent comment

11

u/SAiMRoX Nov 20 '23

OPs function only ever returns false, since the return true is inside another function.

The best way to check for even numbers is:

function isEven(n){
  return n % 2 === 0;
}