题解 | #查找元素位置#

查找元素位置

http://www.nowcoder.com/practice/0a9af9cb20c34babb6232126e019c74d

function findAllOccurrences(arr, target) {
     const res = []
    arr.forEach((item,index)=>{
        if(item===target) {
            res.push(index)
        }
    })

    return res
}

全部评论

相关推荐

给个offer灞:校友 是不是金die
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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