[Solved] Contain word from whole string in javascript [closed]


//Function CheckForWords accepts the text value
//Splits text value on whitespace, iterates each word,
//Checks if each word is found in text, if not returns false
function CheckForWords(text){
   const words = text.split(' ');

   for(let x = 0; x < words.length; x++){
        if(text.toLowerCase().indexOf(words[x].toLowerCase()) === -1){
            return false;
        }
   }

   return true;
}

0

solved Contain word from whole string in javascript [closed]