One way is to use arguments. I can loop over the arguments array and can return the sum of all the arguments passed.
function sum(){
var sum =0;
for(var i=0;i<arguments.length;i++){
sum += arguments[i];
}
return sum;
}
sum(1,2); // returns 3
sum(1,2,3); // returns 6
Is there any other way to do it without using loop?