function sum(){ var result = 0, max = arguments.length; for (var i = 0; i < max; i++){ result += arguments[i]; } return result ; } alert(sum(1,2,3,4,5))