Nodejs Utililty Methods Number Value Check

List of utility methods to do Number Value Check

Description

The list of methods to do Number Value Check are organized into topic(s).

Method

isEven()
Number.prototype.isEven = function(){
  return this % 2 === 0;
isEven()
Number.prototype.isEven = function (){
  return this.isOdd() == false;
isEven()
Number.prototype.isEven = function () { return (this % 2) === 0; }; 
Number.prototype.isOdd = function () { return Math.abs(this % 2) === 1; };
Array.prototype.isEmpty = function () { return this.length === 0; };
Array.prototype.hasItem = function (item) { return this.indexOf(item) >= 0; };
Array.prototype.remove = function (item) {
  var index = this.indexOf(item);
  if (index >= 0)
    this.splice(index, 1);
};
...
isEven()
Number.prototype.isEven = function () {
    if (this % 2 === 0) {
        return true;
    } else return false;
};
function sumFibs(num) {
    var sumFibArr;
    var fibArray = fibArrayGenerator(num);
    fibArray = fibArray.filter(function (value) {
...
isEven()
window.log = console.log;
function fib(num) {
  return (num < 3) ? num : fib(num - 1) + fib(num - 2);
Number.prototype.isEven = function() {
  return (this % 2 === 0) ? true : false;
};
function fibSum() {
  var i = 1,
...
isEven()
Number.prototype.isEven = function() {
    return !(this % 2);
isOdd()
Number.prototype.isOdd = function () {
  return new Boolean(this.valueOf()&1);
isOdd()
function isOdd(num) {
  if (typeof num === 'number') {  
    return ((num % 2) === 1) || ((num % 2) === -1) ? true : false;
  else {
    throw 'Not a number';
console.log(isOdd(3)); 
...
isOdd()
Number.prototype.isOdd = function() {
    return !!(this % 2);
odd()
Number.prototype.odd = function () {
  return (this % 2 == 1)