/..

Dark Mode

Enable Console

The Function

sumMix([])
sumMix(x)

/*
  Given an array of integers as strings and numbers, 
  returns the sum of the array values as if all were numbers.
*/

sumMix([5, '5']); 
// 10

sumMix([52, '144', '12', 67]); 
// 275

Solution by - Need4Swede

How it works

function sumMix(x){
  
  // Initialize sum
  let sum = 0;
  
  // Convert all passed in elements to Numbers and add them to the sum
  x.forEach(element => {
    element = Number(element);
    sum += element;
  })
  
  // Return the sum
  return sum;

}

Alternatively, you can write it like this...

function sumMix(x){

  return x.map(a => +a).reduce((a, b) => a + b);

  /* EXPLANATION:
    TBD
  */

}

Try it yourself - Codewars Source

You can also use my built-in JavaScript console