Nodejs Utililty Methods Array Odd

List of utility methods to do Array Odd

Description

The list of methods to do Array Odd are organized into topic(s).

Method

odd/even()
Array.prototype.odd = function(){
     return this.filter(value => value % 2 == 1)
};
Array.prototype.even = function(){
     return this.filter(value => value % 2 == 0) 
};
const numbers = [1,2,3,4,5,6,7,8];
console.log(numbers.odd());
console.log(numbers.even());
...
odds()
Array.prototype.odds = function () {
  var a = [], o = this;
  for (var i = 0; i < o.length; i++) {
    if (i%2==0) a.push(o[i]);
  return a;
};