Ad

I've made changes that sum method ignores everything but numbers
Also I've refactored code to ES6

Code
Diff
  • const sum = arr => {
      const reducer = (sum, elem) => typeof elem === 'number' ? (sum + elem) : sum
      return arr.reduce(reducer, 0);
    }
    
    
    • function sum(arr) {
    • return arr.reduce((sum, elem) => sum + elem, 0);
    • }
    • const sum = arr => {
    • const reducer = (sum, elem) => typeof elem === 'number' ? (sum + elem) : sum
    • return arr.reduce(reducer, 0);
    • }