How to remove element from array in forEach loop?

前端 未结 7 523
耶瑟儿~
耶瑟儿~ 2020-11-28 03:37

I am trying to remove an element in an array in a forEach loop, but am having trouble with the standard solutions I\'ve seen.

This is what I\'m current

7条回答
  •  执笔经年
    2020-11-28 03:45

    Here is how you should do it:

    review.forEach(function(p,index,object){
       if(review[index] === '\u2022 \u2022 \u2022'){
          console.log('YippeeeE!!!!!!!!!!!!!!!!')
          review.splice(index, 1);
       }
    });
    

提交回复
热议问题