题解 | #Array.reduce#

Array.reduce

https://www.nowcoder.com/practice/213d0ef21cb841de8cf69fcc5ea60eb6

Array.prototype._reduce = function(fn, sum=0) {
            if(typeof fn !== 'function') return  
            for(let i=0;i<this.length;i++){
                sum=fn(sum,this[i])
            }
            return sum
}

全部评论

相关推荐

双尔:你就写拥有ai开发经历,熟练运用提示词,优化ai,提高ai回答质量
点赞 评论 收藏
分享
哇哇的菜鸡oc:他这不叫校招offer,而是实习offer
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务