I'm trying to match inputted text with a list of words from a pre-defined array. However, it's not returning anything, even the console.log doesn't return anything. I can't work out why the out loop isn't initiating. Any help would be greatly appreciated.
var actions = ["north", "south", "east", "west", "up", "down", "get", "take", "pick up", "use", "drop", "open", "close"];
var inputTextBox = document.getElementById("inputTextBox");
inputTextBox.addEventListener("keypress", function(event) {
var stringArray = [];
var x = event.which || event.keyCode;
var inString = inputTextBox.value.toLowerCase();
if (x === 13) {
stringArray = inString.split(" ");
console.log("stringArray is --- " + stringArray + " --- length is " + stringArray.length);
for (var i = 0; i < stringArray; i++) {
console.log("outer loop is " + stringArray[i]);
for (var j = 0; j < actions.length; j++) {
if (stringArray[i] === actions[j]) {
console.log(stringArray[i]);
}
}
}
}
}
<input id="inputTextBox" type="text" maxlength="200" placeholder="words here" autofocus></input>