Here you can find the source of toTwenty()
Array.prototype.toTwenty = function() { var newArray = []; for (var i = 1; i <= 20; i++) { newArray.push(i);//from w w w. j av a 2 s. co m } return newArray; } Array.prototype.toForty = function() { var newArray = []; for (var i = 2; i <= 40; i += 2) { newArray.push(i); } return newArray; } Array.prototype.toOneThousand = function() { var newArray = []; for (var i = 10; i <= 1000; i += 10) { newArray.push(i); } return newArray; } Array.prototype.search = function(num) { var index = -1; var startIndex = 0; var stopIndex = this.length - 1; var middle; var count = 0; while(startIndex < stopIndex) { middle = Math.floor((startIndex + stopIndex) / 2); if (this[startIndex] === num) { index = startIndex; break; } else if (this[stopIndex] === num) { index = stopIndex; break; } else if (this[middle] < num) { startIndex = middle + 1; } else if (this[middle] > num) { stopIndex = middle - 1; } else { index = middle; break; } count++; } return {"count": count, "index": index, "length": this.length}; }
'use strict'; Array.prototype.toTwenty = function() { let arr = []; for (var i = 1; i <= 20; i++) { arr.push(i); return arr; Array.prototype.toForty = function() { ...
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); ...
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); ...
const binarySearch = function binarySearch (){ Array.prototype.toTwenty = function () { for (var i = 1; i <= 20; i++){ this.push(i); return this; }; Array.prototype.toForty = function () { for (var i = 2; i <= 40; i+=2){ ...
Array.prototype.toTwenty = function(){ var answer=[]; for (var i=1; i<=20; i++){ answer.push(i) return answer; Array.prototype.toForty = function(){ var answer=[]; ...
Array.prototype.toTwenty = function(){ var array = new Array(); for(var i = 1; i <= 20; i++){ array.push(i); return array; }; Array.prototype.toForty = function(){ var array = new Array(); ...