Here you can find the source of toTwenty()
Array.prototype.toTwenty = function(){ var answer=[];//from ww w . ja v a 2 s. c o m for (var i=1; i<=20; i++){ answer.push(i) } return answer; } Array.prototype.toForty = function(){ var answer=[]; for (var i=2; i<=40; i=i+2){ answer.push(i) } return answer; } Array.prototype.toOneThousand = function(){ var answer=[]; for (var i=10; i<=1000; i=i+10){ answer.push(i) } return answer; } Array.prototype.search = function(d){ var minIndex = 0; var maxIndex = this.length - 1; var currentElement; var count=0; while(minIndex <= maxIndex) { currentElement = Math.floor((maxIndex + minIndex) / 2); if (this[currentElement] === d) { return {index:currentElement, count:count}; } else if (this[currentElement] < d) { minIndex = currentElement + 1; count=0; } else if (this[currentElement] > d) { minIndex = currentElement - 1; count+=0; } else { maxIndex = currentElement - 1; count+=1; } } return {index:-1, count:count, length:this.length}; }
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 = []; ...
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 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);}
Array.prototype.toTwenty = function() { 'use strict'; var arr = []; var count = 0; for (var i = 1; i <= 20; i++) { count += i; arr.push(i); return arr; ...