Rest Operator
Sun Jun 18 2023 14:56:28 GMT+0000 (Coordinated Universal Time)
Saved by
@pratik1021
function Add(...theArgs) {
let total = 0;
for (let arg of theArgs) {
total += arg;
}
return total;
}
console.log(Add(1, 2, 3,4,5,6,7,8,9,10));
// Expected output: 55
console.log(Add(11,22,33,44,55,66,77,88,99));
// Expected output: 495
content_copyCOPY
Comments