Skip to content

Instantly share code, notes, and snippets.

@mavitm
Created July 21, 2017 23:10
Show Gist options
  • Save mavitm/809477feee51a486abe59f1e8207d5a0 to your computer and use it in GitHub Desktop.
Save mavitm/809477feee51a486abe59f1e8207d5a0 to your computer and use it in GitHub Desktop.
var indexFinder = function( maxItem, maxNumber, optionalParam ){
this.maxItem = maxItem,
this.maxNumber = maxNumber,
this.optionalParam = optionalParam,
this.myArray = [],
this.arrindexs = [],
this.tools = {
randomNumber : function randomNumber( min, Max ){
return Math.floor(( Math.random() * Max ) + min )
},
arrFilled : function( maxItem, random ){
if( random ){
return this.arrShufle( this.arrFilled( maxItem, false ) )
}
return Object.keys( new Array( maxItem - 1 ).fill( 0 ) );
},
arrShufle : function(arr){
return arr.sort(function() {
return .5 - Math.random();
});
},
arrValues : function(arr){
returnvar = [];
var x = 0;
for(i in arr){
returnvar[x] = arr[i];
x++;
}
return returnvar;
}
},
this.collectionResult = function(arr){
var split = 0;
var arrLength = arr.length;
var x = 0;
for(i in arr){
if(( arr[i] + arr[arrLength - x] ) > this.maxNumber ){
split++;
}
x++;
}
return split;
},
this.canBeUsed = function(){
var arr = this.tools.arrFilled( Math.max( this.maxItem, this.maxNumber ), true );
this.myArray = arr.slice(0, this.maxItem).sort(function(a, b){return b-a});
this.myArray = this.tools.arrValues(this.myArray);
console.log("sdsad");
//alert( this.collectionResult( this.myArray ) );
};
};
var a = new indexFinder(20, 100);
a.canBeUsed();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment