Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to remove element from array in forEach

const review = ["a", "b", "c", "b", "a"];

review.forEach((item, index, arr) => {
  if (item === "a") {
    arr.splice(index, 1);
  }
});
Source by thewebdev.info #
 
PREVIOUS NEXT
Tagged: #remove #element #array #forEach
ADD COMMENT
Topic
Name
6+2 =