One-liner JavaScript - Odd or Even

One-liner JavaScript - Odd or Even


Welcome to a new series of JavaScript codes where I try to post a one-liner JavaScript function. This first code is a one-liner code for determining if a number is odd or even:

const isEven = (num) => !Boolean(num % 2);
const isOdd = (num) => Boolean(num % 2);

 

 

How do you rate this article?

1



k88.io Presents: Programming
k88.io Presents: Programming

Just another blog about programming, tricks and tutorials.

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.