Determine if N is Even I was playing with JS and wanted to create an isEven(n) function that returns true if it is even and false otherwise.

Here is what I did:

function isEven(n){
  return n % 2 ? false : true;
}

print(isEven(6));
//-&gt; true
print(isEven(-3));
//-&gt; false 


My question is: 

Is this good code? How is JS interpreting this code? 

I'm assuming JS returns true if n % 2 equals to 1 and false if 0.

Is this a good solution or would you prefer writting something else like:

function isEven(n){
   return (n % 2 == 0) ? true : false;
}    
print(isEven(6));
//-&gt; true
print(isEven(-3));
//-&gt; false
First, a number X is even if X mod 2 is 0.

I think is more understandable something like this:

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


The function will return true if the number n is even and false if it's odd.