← Back to challenges

Sum of Number Elements in an Array

JavaScriptHardarraysalgebravalidationconditions

Instructions

Arrays can be mixed with various types. Your task for this challenge is to sum all the number elements in the given array. Create a function that takes an array and returns the sum of all numbers in the array.

Examples

numbersSum([1, 2, "13", "4", "645"]) ➞ 3

numbersSum([true, false, "123", "75"]) ➞ 0

numbersSum([1, 2, 3, 4, 5, true]) ➞ 15

Notes

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Finding Nemo