How to remove the matching element of the array

arrays, javascript

Solution

Find the index of the word, then use splice to remove it from your array.

var array = ['html', 'css', 'perl', 'c', 'java', 'javascript']  
var index = array.indexOf('perl');

if (index > -1) {
    array.splice(index, 1);
}

Problem

I have one array in JavaScript: ``` ['html', 'css', 'perl', 'c', 'java', 'javascript'] ``` How can I delete "perl" element? There has to be removing the third element. It must be to remove the element with a value of "perl".

Original source

Related problems