How to check that a text contains the words of an array

Viewed 15

I need to separate a text (split) and compare that the array is inside a value Example: var myTextLarge = 'Hello my love world' var textToCompare = 'Hello world' //

I try this, but

const textLarge = 'Hello my love world'
const message = 'Hello world'

var aux = message.split(' ');
console.log(textLarge.includes(aux[0]) && textLarge.includes(aux[1]))

I have tried this but I don't want to hardcode the comparison, it must be dynamic. is it possible with some function? Or should I use a loop

0 Answers
Related