By using REST parametrs we can sum infinite number of arguments as an array
function sum(...argslist) { return argslist.reduce((prev,current)=>{ return prev+current; }); } sum(1); //Output : 1 sum(1,2,3); //Output : 6
Related
JavaScript Average Program using Arrow Function