Dark Mode
Enable Console
squareSum(numbers)
/*
Cubes all passed in numbers and sums them up
Returns sum total
*/
squareSum([1, 2, 3]);
// 14
squareSum([12, 5, 44]);
// 2105
Solution by - Need4Swede
function squareSum(numbers){
// Initialize sum variable
let sum = 0;
// Cube every number passed in and add it to the sum total
numbers.forEach(number => {
number **= 2;
sum += number;
})
// Return the sum total
return sum;
}
Try it yourself - Codewars Source