function sa() { var len = arguments.length; if (len == 0) return "X3"; var sum = 0; for (var i = 0; i < len; i++) { sum += +arguments[i]; } return sum/len; } alert(sa(4, 2, 3)); alert(sa('4', '2', '3')); alert(sa());