Categories
JavaScript Answers

How to search and remove string within a JavaScript array?

Spread the love

To search and remove string within a JavaScript array, we use the filter method.

For instance, we write

const arr = ["A", "B", "C"];
const filteredArr = arr.filter((e) => e !== "B");

to call arr.filter to return an array without 'B' in it.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *