You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You are given an initial 2-value array (x). You will use this to calculate a score.
If both values in (x) are numbers, the score is the sum of the two. If only one is a number, the score is that number. If neither is a number, return 'Void!'.
Once you have your score, you must return an array of arrays. Each sub array will be the same as (x) and the number of sub arrays should be equal to the score.
For example:
if (x) == ['a', 3] you should return [['a', 3], ['a', 3], ['a', 3]].
*/
function explode(x) {
let score = 0;
if (x.every(el => typeof el === 'number')) {
score += x.reduce((acc, c) => acc + c, 0);
} else if (x.some(el => typeof el === 'number')) {
score += x.filter(el => typeof el === 'number').reduce((acc, c) => acc + c, 0);