Check if a string includes one of multiple values

Let's assume that you want to check if a string includes one of a series of values.

Example:

javascript
let os = 'macOS'

let series = ['mac', 'Mac', 'os']

let hasWord = series.some(word => os.includes(word))
// true

In one line of code:

javascript
let hasWord = ['mac', 'Mac', 'os'].some(word => 'macOS'.includes(word))

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.