I have a known value to compare
var sT = 100;
with an array of random values and an unknown length
var someArray = [12, 21, 3, 54, 5, ... ]
I then want to add each number to all previous values
var one = someArray[0];
var two = someArray[0]+someArray[1];
var three = someArray[0]+someArray[1]+someArray[2];
// ...
or possibly I could do something like this?
var otherArray = [];
someArray.forEach(function(i){
otherArray.push(i+=i);
somefunction();
});
function somefunction() {
otherArray.forEach(function(i){
// ?
})
}
then I need to check the value of the array starting at 'one' like so...
var int;
if ( sT <= one ){
int = 1;
}
else if ( sT >= one && sT <= two ) {
int = 2;
}
else if ( sT >= two && sT <= three ) {
int = 3;
}
else if ...
// until the last
else if ( sT >= twenty*0.8 ) {
int = 20;
}
Is there a way to do this much more programmatically?