题解 | #Array.reduce#

Array.reduce

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

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <style>
       /* 填写样式 */
    </style>
</head>

<body>
    <!-- 填写标签 -->
    <script type="text/javascript">
        // 填写JavaScript
        Array.prototype._reduce = function(Fn){
            if(typeof Fn !== 'function')return
            let sum = 0
            for(let i = 0;i < this.length-1;i++){
               sum += Fn(this[i],this[i+1])
            }
            return sum
        }
    </script>
</body>

</html>

全部评论

相关推荐

10-02 19:29
已编辑
浙江科技大学 运营
点赞 评论 收藏
分享
ResourceUt...:楼主有自己的垃圾箱,公司也有自己的人才库
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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