Sum an Array of Numbers with JavaScript

It’s rare that I’m disappointed by the JavaScript language not having a function that I need. One such case was summing an array of numbers — I was expecting Math.sum or a likewise, baked in API. Fear not — summing an array of numbers is easy using Array.prototype.reduce! const numbers = [1, 2, 3, 4]; […]

The post Sum an Array of Numbers with JavaScript appeared first on David Walsh Blog.

Visit Website
twittergithub
logo

Copyright © 2022-2024 - Aetos