r/javascript • • Mar 18 '19

What's your favorite, most useful javascript one-liner?

385 Upvotes

422 comments sorted by

View all comments

Show parent comments

3

u/NoInkling Mar 19 '19

Not a thing in JS.

-1

u/Michie1 Mar 19 '19

Wow, you are right. Math.sum is not a function. I'm confusing it with Math.min/max and was extrapolating it would exist for sum.

The following package should work:

import * as math from 'mathjs';
math.sum(arr);