Here you can find the source of odd()
Array.prototype.odd = function() { var ret = new Array(); this.forEach(function(a) { if (0 != a % 2) { ret.push(a);//w w w . ja va 2 s . com } }); return ret; }
Array.prototype.odd = function(){ return this.filter( x => x % 2 != 0 )
Array.prototype.odd = function(){ return this.filter((element) => element % 2 !== 0);
Array.prototype.odd = function () { return this.filter(function(value) { return value % 2 != 0; });
Array.prototype.odd = function () { return this.filter(function (e) { return e % 2; }); };
Array.prototype.odd = function () { return this.filter((item) => { return item % 2 === 1; }); };
Array.prototype.odd = function(){ var newArr = []; for (var i of this){ if (i % 2 !== 0){ newArr.push(i); return newArr;
Array.prototype.odd = function(){ return this.filter(x=> x%2 == 1?x:'');
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()); ...
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; };