Javascript Array toForty()
Array.prototype.toForty = function(){ var start = 2; var end = 40; for(var i = start; i <= end; i += 2){ this.push(i);//from w w w . ja v a 2s . c o m } return this; } var oneToForty = [].toForty(); console.log(oneToForty);
Array.prototype.toForty = function() { return Array.range(40, 2); };
Array.prototype.toForty = function(){ b = [];//ww w . j a v a2 s . co m for(i=2; i<=40; i+=2){ b.push(i); } return b }