5 Answers
New Answerfirst split all the words into an array const words = "Full Word".split(" ") // this will split the phrase from where ever it finds " ", i.e. a space. So now, words is equal to [ "Full", "Word" ] let found = false // use appropriate variable names, such as found. // 'includes' also works on arrays, and it doesn't match the substrings when used with array. if (words.includes("Fu")) found = true document.getElementById("demo").innerHTML = found
You can split your sentence into array. var array = entry.split(" "); Then loop over the array to find the exact word. 🚀
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message