Closed RazvanBugoi closed 4 years ago
function cubeOdd(arr) {
let odd = [];
let cubed = arr.map((el) => Math.pow(el, 3));
if (arr.filter((element) => typeof(element) == 'number').length == arr.length) {
for (let i=0; i<cubed.length; i++) {
if (cubed[i] % 2 != 0) odd.push(cubed[i]);
}
return odd.reduce((a,b) => a+b, 0);
} else {
return undefined;
}
}
https://www.codewars.com/kata/580dda86c40fa6c45f00028a/train/javascript