Nodejs Array Odd odd()

Here you can find the source of odd()

Method Source Code

Array.prototype.odd = function () {
  return this.filter((item) => {
    return item % 2 === 1;
  });//ww  w .  ja  v a 2s.  c om
};

Related

  1. odd()
    Array.prototype.odd =  function() {
      var odd = function(value, index) {
        if ((index + 1) % 2) {
          return value;
      };
      return this.filter(odd);
    };
    var a = [1, 2, 3, 4, 'odd', 'even'];
    ...
    
  2. odd()
    Array.prototype.odd = function(){
      return this.filter( x => x % 2 != 0 )
    
  3. odd()
    Array.prototype.odd = function(){
        return this.filter((element) => element % 2 !== 0);
    
  4. odd()
    Array.prototype.odd = function () { 
      return this.filter(function(value) { 
        return value % 2 != 0; 
      }); 
    
  5. odd()
    Array.prototype.odd = function () {
      return this.filter(function (e) {
        return e % 2;
      });
    };
    
  6. odd()
    Array.prototype.odd = function()
      var ret = new Array();
      this.forEach(function(a) {
        if (0 != a % 2) {
          ret.push(a);
      });
      return ret;
    ...
    
  7. odd()
    Array.prototype.odd = function(){
      var newArr = [];
      for (var i of this){
        if (i % 2 !== 0){
          newArr.push(i);
      return newArr;
    
  8. odd()
    Array.prototype.odd = function(){
      return this.filter(x=> x%2 == 1?x:'');
    
  9. 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());
    ...