JavaScript 在Javascript中测试偶数/奇数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript 在Javascript中测试偶数/奇数相关的知识,希望对你有一定的参考价值。

var isEven = function(someNumber){
    return (someNumber%2 == 0) ? true : false;
};

alert(isEven(64)); // Alerts "true".

alert(isEven(97)); // Alerts "false".

以上是关于JavaScript 在Javascript中测试偶数/奇数的主要内容,如果未能解决你的问题,请参考以下文章