求任意一组数的平均值

js

        <script type="text/javascript">
            function getAvg() {
                var sum = 0, len = arguments.length, i;
                for(i = 0; i<len; i++) {
                    sum += arguments[i];
                }
                return sum/len;
            }

            var avg = getAvg(11,22,33,44,88)
            console.log(avg)
        </script>

 

posted @ 2020-06-11 15:24  嘆世殘者——華帥  阅读(153)  评论(0编辑  收藏  举报