I'm trying to check if is true or false the letter I typed.
for exemplo, I have one String that I caught from a array doing join(' '):
"problem test javascript css pc"
My current code:
document.addEventListener('keydown', (event) => {
let count = 0
let charlist = "problem test javascript css pc"
for(let i = 0; i < charlist.length; i++){
if(charlist[i] === event.key){
count++
console.log(count)
}
}
})
When I type "s" is counting 2, and when I type "t" is counting 3, there is no sequence..
What I need is check just the first letter "p" and count 1 return true, type letter "r" count 1 return true
how can I test this ?