Here you can find the source of toTwenty()
'use strict';//from w ww . java2 s . co m Array.prototype.toTwenty = function() { let arr = []; for (var i = 1; i <= 20; i++) { arr.push(i); } return arr; } Array.prototype.toForty = function() { let arr = []; for (var i = 2; i <= 40; i += 2) { arr.push(i); } return arr; } Array.prototype.toOneThousand = function() { let arr = []; for (var i = 10; i <= 1000; i += 10) { arr.push(i); } return arr; } Array.prototype.search = function(num) { var index = -1; var minIndex = 0; var maxIndex = this.length - 1; var midIndex; var count = 0; while(minIndex <= maxIndex) { midIndex = ~~((minIndex + maxIndex) / 2); if (this[minIndex] === num) { index = minIndex; break; } else if (this[maxIndex] === num) { index = maxIndex; break; } else if (this[midIndex] < num) { minIndex = midIndex + 1; } else if (this[midIndex] > num) { maxIndex = midIndex - 1; } else { index = midIndex; break; } count++; } return {"count": count, "index": index, "length": this.length}; }
Array.prototype.toTwenty = function() { for (var i = 1; i < 21; i++) { this.push(i); return this; },
Array.prototype.toTwenty = function(){ var start = 1; var end = 20; for(var i = start; i <= end; i += 1){ this.push(i); return this; var oneToTwenty = [].toTwenty(); */ ...
Array.prototype.toTwenty = function(){ var start = 1; var end = 20; for(var i = start; i <= end; i += 1){ this.push(i); return this; Array.prototype.toForty = function(){ ...
Array.prototype.toTwenty = function() { return Array.range(20, 1); };
Array.prototype.toTwenty = function(){ a = 1; b = []; for(i=1; i<=20; i++){ b.push(i); return b
Array.prototype.toTwenty = function(){ for(var loop =1; loop<=20;loop++){ this.push(loop); return this; }; Array.prototype.toForty = function(){ for(var loop = 1;loop<=20;loop++){ this.push(loop*2); ...
Array.prototype.toTwenty = function() { var arr = []; for (i = 0; i < 20; i++) { arr.push(i+1); return arr; Array.prototype.toForty = function() { var arr = []; ...
Array.prototype.toTwenty = function(){ var twenty = []; for ( var i = 1; i <= 20; i++){ twenty.push(i) return twenty Array.prototype.toForty = function() { var forty = []; ...
Array.prototype.toTwenty = function() { for(let i=1; i<=20; i++) { this.push(i); return this; Array.prototype.toForty = function() { for(let i=2; i<=40; i+=2) { this.push(i); ...