[JavaScript] How to remove a given string from an array?
I want to remove a specific string from an array, how can I do that in JavaScript?
1 Answer
4 years ago by Anusha
Consider you want to remove the string 'five' from the below array, you can use the filter like below:
let givenArray = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
let filteredArray = givenArray.filter((value) => value !== 'five');
Try checking the result here: https://onecompiler.com/javascript/3xmt6b92f
4 years ago by Meera