Math.sum or a likewise, baked in API. Fear not — summing an array of numbers is easy using
const numbers = [1, 2, 3, 4]; const sum = numbers.reduce((a, b) => a + b, 0);
0 represents the starting value while with
b, one represents the running total with the other representing the value to be added. You’ll also note that using
reduce prevents side effects! I’d still prefer something like
Math.sum(...numbers) but a simple
reduce will do!
As much as developers now loathe Flash, we’re still playing a bit of catch up to natively duplicate the animation capabilities that Adobe’s old technology provided us. Of course we have canvas, an awesome technology, one which I highlighted 9 mind-blowing demos. Another technology available…