0

I have a string that I'd like to fuzzy match on, I've tried using ES6 includes but it doesn't seem to match the conditions where I'd like it to.

const station = 'virginia square-gmu george mason university'

When I do the following I end up getting false even though all of the words are included inside of station.

station.includes('virginia square george mason university')
> false

What would be the correct way to see if station includes any combination of the words passed into the includes statement, would RegEx be a good candidate for this?

1 Answer 1

4

split the words into an array and use every to check that each word is contained within the string.

const station = 'virginia square-gmu george mason university'
const words = 'virginia square george mason university';

const all = words.split(' ').every(word => station.includes(word));
console.log(all);

Sign up to request clarification or add additional context in comments.

Comments

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.