Sum of all Evens in a Matrix

Published by Helen Yu in

Create a function that returns the sum of all even elements in a 2D matrix.

Examples

sumOfEvens([
  [1, 0, 2],
  [5, 5, 7],
  [9, 4, 3]
]) ➞ 6
// 2 + 4 = 6

sumOfEvens([
  [1, 1],
  [1, 1]
]) ➞ 0

sumOfEvens([
  [42, 9],
  [16, 8]
]) ➞ 66

Notes

N/A

Watch a quick demo on how Edabit works.