How to determine if a number is odd in JavaScript

后端 未结 27 1820
一向
一向 2020-11-27 10:05

Can anyone point me to some code to determine if a number in JavaScript is even or odd?

27条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 10:57

    This can be solved with a small snippet of code:

    function isEven(value) {
        return !(value % 2)
    }
    

    Hope this helps :)

提交回复
热议问题