This is what is understand from your question and try to solve your issue.
const arr = [1441,1468,1445,1512,1621,1000];
let finalAnswer = [];
for(let i = 1;i<arr.length;i++)
{
finalAnswer.push(arr[i-1] - arr[i]);
}
console.log(finalAnswer);
Answer from Ferin Patel on Stack OverflowThis is what is understand from your question and try to solve your issue.
const arr = [1441,1468,1445,1512,1621,1000];
let finalAnswer = [];
for(let i = 1;i<arr.length;i++)
{
finalAnswer.push(arr[i-1] - arr[i]);
}
console.log(finalAnswer);
Not totally sure what you want as a final result. Maybe this would work for you.
getStats()
.then(stats => {
let eloArr = [stats[0].elo];
console.log(eloArr[0]);
let total = stats[0].elo;
for (let i = 1; i < stats.length; i++) {
eloArr.push(stats[i].elo);
console.log(stats[i].elo);
total -= stats[i].elo;
}
console.log(total);
});
Videos
For some number y and some divisor x compute the quotient (quotient)[1] and remainder (remainder) as:
const quotient = Math.floor(y/x);
const remainder = y % x;
Example:
const quotient = Math.floor(13/3); // => 4 => the times 3 fits into 13
const remainder = 13 % 3; // => 1
[1] The integer number resulting from the division of one number by another
I'm no expert in bitwise operators, but here's another way to get the whole number:
var num = ~~(a / b);
This will work properly for negative numbers as well, while Math.floor() will round in the wrong direction.
This seems correct as well:
var num = (a / b) >> 0;
Note: Only use ~~ as a substitution for Math.trunc() when you are confident that the range of input falls within the range of 32-bit integers.