We just need one line of code for this!
Here a newer and alternative way to do this, using the new ES6 syntax for JS functions, and the one-line syntax for the if-else
statement call:
const isEven = num => ((num % 2) == 0) ? true : false;
alert(isEven(8)); //true
alert(isEven(9)); //false
alert(isEven(-8)); //true