JSFiddle - React, Tailwind, and code Playground
JavaScript
var myText = "what makes the desert: beautiful, said the little prince is that somewhere it hides a well";
function wordSearch(word, text){
var result = false;
text.replace(/[.,;:]/g, '').split(" ").forEach(function(d){
if (d === word) {
result = true;
}
})
return result
}
console.log(wordSearch("desert", myText))