You are viewing a single comment's thread from:

RE: Basic Tutorial Javascript : Learn To Program To Determine Odd Number Or Even Number

in #utopian-io7 years ago

Remember JS evaluates numbers as booleans as C does, so the == 0 part in the if sentence is not needed. If you still want to use it, do it a triple equals (===) instead.

You can better write a simple function as:

function isOdd(n) {
  return n % 2;
}

isOdd(5)  // returns true
isOdd(4)  // returns false
Sort:  

Thank you for your advice

Coin Marketplace

STEEM 0.20
TRX 0.14
JST 0.030
BTC 68845.40
ETH 3281.32
USDT 1.00
SBD 2.65