Hello World

数组

1. 累加求和

    const array1 = [1,3,5,7,9]

    // 数据累加
    function sum(...numbers){
        return numbers.reduce((preValue,currentValue)=>{
          return preValue + currentValue
        })
    }
    // 必须用展开语法传参,不能直接传数组对象
    console.log(sum(...array1)) // 25
posted @ 2021-11-25 22:20  小小忧愁米粒大  阅读(63)  评论(0编辑  收藏  举报
瞅啥瞅,好好看书