function test(...rest) { // let arr = rest return rest.flat(Infinity).reduce((sum, num) => sum + Number(num), 0) } console.log(test(1, 2, 3, 4)) console.log(test([1, 2, 3, 4]))