I was just tweaking some code in JS and ended up writing the below code.
const adding=(a,b,c,d)=> {
return(a+b, c+d)
}
let sum1, sum2 = adding(1,2,3,4)
console.log(sum1)
console.log(sum2)
The output was Undefined 7
And when I changed the position of return values like below
const adding=(a,b,c,d)=> {
return(c+d, a+b)
}
let sum1, sum2 = adding(1,2,3,4)
console.log(sum1)
console.log(sum2)
The out put was Undefined 3
My question is Why?