Chartjs-JavaScript. Find the sum of a certain parameter in an array to produce a popup if that sum == 0

0👍

You can use Array.prototype.reduce, here is the complete code

if (data.reduce((a, v) => a + v.y, 0) === 0) {
  alert('The sum of data.y is zero!');
}

Leave a comment