Answers for "how to remove element from array in foreach javascript"

0

how to remove element from array in foreach javascript

var pre = document.getElementById('out');

function log(result) {
  pre.appendChild(document.createTextNode(result + '\n'));
}

var review = ['a', 'a', 'b', 'c', 'b', 'a', 'a'],
  index = review.indexOf('a');

while (index !== -1) {
  review.splice(index, 1);
  index = review.indexOf('a');
}

log(review);
Posted by: Guest on April-10-2021

Code answers related to "how to remove element from array in foreach javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language