I'm solving a CodeWars kata.
This is my code:
function partsSums(arr) {
let bigSum = [];
if (arr.length == 0) {
bigSum.push(0);
}
while (arr.length >= 1) {
let sum = arr.reduce((acc, ele) => acc + ele);
bigSum.push(sum);
partsSums(arr.shift());
}
return bigSum;
}
The correct answer should be: [20, 20, 19, 16, 10, 0]
My function returns: [ 20, 20, 19, 16, 10 ]
Please point out where I'm wrong or my misunderstanding. Thank you!