0
const myArray = ['Dart V', 'Skywalker L', 'Skywalker E'];
const myString = 'walk';

Needed to filter by 'walk'.

Want to get:

const filteredArray = ['Skywalker L', 'Skywalker E'];

1 Answer 1

1
const filteredArray = myArray.filter((item) => item.toLowerCase().indexOf('walk') !== -1);
Sign up to request clarification or add additional context in comments.

1 Comment

myArray.filter((item) => item.includes('walk')); is even more concise

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.