I am trying to match keycodes to the sent1Array. How do I make the forEach go to the next number in my array?


Ask A Question





Login To post a question

If I type the first letter(“T”), I get “Congrats”. If I type the next letter(“h”), I get “Nope” because it hasn’t moved to the next keycode in my array. I need to move to the next letter in the array and match it to the next keycode.

var sent1Array = [84, 72, 69, 32, 81, 85, 73];
input1.addEventListener("keydown", function(event) {
 sent1Array.forEach(function() {
        for (var i = 0; i < 1; i++) {
            if (sent1Array[i] === event.keyCode) {
                console.log("Congrats");
            } else {
                console.log("Nope");
            }
        }
    })
    });

For more info please click herehttps://stackoverflow.com/q/57643325



Have a question or need a custom quote?
info@smartinfocare.com