Here you can find the source of toTwenty()
Array.prototype.toTwenty = function(){ for(var loop =1; loop<=20;loop++){ this.push(loop);//w w w . j ava 2 s.c o m } return this; }; Array.prototype.toForty = function(){ for(var loop = 1;loop<=20;loop++){ this.push(loop*2); } return this; }; Array.prototype.toOneThousand = function(){ for(var loop =1; loop<=100;loop++){ this.push(loop*10); } return this; }; Array.prototype.search = function(number){ first =0; last = this.length-1; var n = this.length; var output = {count:0, index:-1, length:n}; while(first<=last){ var mid = Math.floor((first+last)/2); if(this[first]==number){ output.index=first; return output; }else if(this[last]==number){ output.index=last; return output; }else if(this[mid]==number){ output.index = mid; return output; }else if(this[mid]<number){ first = mid+1; last -=1; }else{ last = mid -1; first +=1; } output.count ++; } return output; }; module.exports = Array;
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() { var newArray = []; for (var i = 1; i <= 20; i++) { newArray.push(i); return newArray; Array.prototype.toForty = function() { var newArray = []; ...
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(); ...
var oneToTwenty = [].toTwenty(); var twoToForty = [].toForty(); var tenToOneThousand = [].toOneThousand(); Array.prototype.toTwenty = function(){ var start = 1; var end = 20; for(var i = start; i <= end; i += 1){ result.push(i); return result; Array.prototype.toForty = function(){ var start = 2; var end = 40; for(var i = start; i <= end; i += 2){ result.push(i); return result; Array.prototype.toOneThousand = function(){ var start = 10; var end = 1000; for(var i = start; i <= end; i += 10){ result.push(i); return result; var tenToOneThousand = [].toOneThousand(); Array.prototype.Search = function(d) { start = start || 0; end = end || this.length; var ind = Math.floor(end + start) / 2; if(!search) {return "Nothing to search";} if(result[ind] == search) { return ind;} else if(result[ind] < search) {return result.Search(search, ind, end);} else {return result.Search(search, start, ind);}