Can you help me create a function that will detect if a user types one of the strings from a list and then output which string was typed in the console?
HTML
<input id="inputText"></input>
JS
window.onload = function(){
var inputText = document.getElementById('inputText');
var stringsToDetect = ["apple", "banana", "orange", "grape"]
inputText.onkeypress = function (e) {
if (stringsToDetect.includes(inputText.value)) {
console.log("User typed: " + inputText.value)
}
};
}