How to use the forEach function from mathjs

Find comprehensive JavaScript mathjs.forEach code examples handpicked from public code repositorys.

0
1
2
3
4
5
6
7
8
const math = require('mathjs');

// Finds the sum of all the elements in an array
const sum = (array) => {
  let total = 0;
  math.forEach(array, (val) => {
    // Itterate through the array, adding to the total variable
    total += val;
  });
fork icon1
star icon6
watch icon3

+ 5 other calls in file

2
3
4
5
6
7
8
9
10
var math = require('mathjs');

// Finds the sum of all the elements in an array
var sum = function sum(array) {
  var total = 0;
  math.forEach(array, function (val) {
    // Itterate through the array, adding to the total variable
    total += val;
  });
fork icon1
star icon6
watch icon3