JavaScript ES6 - Use the Rest Parameter with Function Parameters

I’m having troubles knowing the difference between these two recursive functions:

This will output the corrected answer:

const sum = (args) => {
var total = 0
if (args.length === 0){
return 0
}
else {
return args[0] + sum(args.slice(1));
}
}
console.log(sum([1, 2, 3])); // 6

And this will not:

const sum = (...args) => {
var total = 0
if (args.length === 0){
return 0
}
else {
return args[0] + sum(args.slice(1));
}
}
console.log(sum(1, 2, 3)); // 6

Shouldn’t the Rest … turn the args value into an array? Or am I interpreting that wrong?

here you are passing one single element to the sum argument, it’s an array.
So then the rest parameter put this single element inside the args array parameter of the function, so now args has value of [[2,3]]

do you get the issue?
you can fix it using the spread parameter there

That makes sense!
Thank you!