Sense keywords in an input?

I’m trying to detect keywords in an input, but I can’t find anything explaining how to do that. I am focusing on keywords instead of alphabets, note. I only know javascript, HTML and css, so if this can’t be done using just these three, please also let me know, and I’m sorry for the trouble. Thanks in advance

Hey @penguinlino,

You can use the JS property .includes() of strings to find it has a certain word.

var str = "hi, hello world i am hungry" // or you can get the values using DOM
// like this
// var str = document.getElementById("input-id").value;
let hasword = str.includes("hungry"); // returns true

.includes() property returns true if the word exists, or else it returns false.

2 Likes

Somehow I didn’t know about includes() and have been using ridiculous RegExpressions forever. Thank you for saving future me tons of time and frustration!

1 Like