somebody should help me here, the array is returning [3, 0], where are my missing something?

Given a non-empty array, if there is a place to split the array so that the sum of the numbers on one

side is equal to the sum of the numbers on the other side return the length of the two arrays as an array but

if there is no place to split the array, return -1

```
canBalance([1, 1, 1, 2, 1]) → [3,2]
canBalance([2, 1, 1, 2, 1]) → -1
canBalance([10, 10]) → [1,1]
```

```
function sol(arr){
let y = 0;
let c = 0;
let d = [];
//let a = []
// a = arr.sort((a,b) => a - b);
arr.forEach((x) => y +=x);
for(let i = 0; i < arr.length; i++){
c += arr[i];
if(c == y/2){
d.push(arr.splice(0, i+1).length);
d.push(arr.splice(i+1).length)
}
}
return d;
}
const a = [2, 3, 4, 5, 1, 3]
console.log(sol(a))
```