this is a kata from codewars, here is the description of the kata:

think of a Quadribonacci starting with a signature of 4 elements and each following element is the sum of the 4 previous, a Pentabonacci (well Cinquebonacci would probably sound a bit more Italian, but it would also sound really awful) with a signature of 5 elements and each following element is the sum of the 5 previous, and so on.

Well, guess what? You have to build an Xbonacci function that takes a signature of X elements – and remember each next element is the sum of the last X elements – and returns the first n elements of the so seeded sequence.

and this is my solution to it:

```
function Xbonacci(signature,n){
let i=0;
let k = n - signature.length;
while(k--){
let sumNums = 0;
//let newArray = (...signature);
signature.slice(i , signature.length ).map((num)=>{
return sumNums += num;
})
signature.push(sumNums);
i++
}
return signature;
}
```

the code works well but it doesn’t pass the test because of optimization. Is there any way to make this code faster or more optimized? I think the problem is the slice method but I don’t what to use it instead.