js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Use reduce() to calculate the sum of the values in an array #515

Closed RazvanBugoi closed 4 years ago

RazvanBugoi commented 4 years ago

https://www.codewars.com/kata/532b4057484b0e58e8000766/train/javascript

RazvanBugoi commented 4 years ago
function sum(array) {
  return array.reduce((a,b) => a + b, 0);
}