js求数字的平均值

求数字的平均值

    <script>
        const average = (...args) => args.reduce((a, b) => a + b) / args.length;
        console.log(average(1, 2, 3, 4));; // Result: 2.5
    </script>
posted @ 2021-11-12 17:19  江咏之  阅读(147)  评论(0编辑  收藏  举报