展开全部
<script type="text/javascript">
function sum() {
var len = arguments.length;
var s = 0;
for(var i=0; i < len; i++) {
if(!isNaN(arguments[i])) {
s+=Number(arguments[i]);
}
}
return s;
}
console.log(sum(1,2,3,4,5));
console.log(sum(1,2,3,4,5,6,"a","7"));
console.log(sum("a","b","c","d","e"));
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询