Typing game with Javascript
course from Brad Traversy
Features:
localStorage get and set
setting difficulty selects
matching words
score add when correct
time reduces and the time add if typing correctly(time depends on difficulty level)
HTML
button controls the setting section at the topthe setting is a form with three selections
the text input compare to the word when the user types
time on the left, score on the right
and when the game end, the message shows up with the score and a reset button
CSS
hide the arrow on the select with appearance, for other browser adding the -webkit and -mozWhen focusing on select, hiding the outline
the messager box show at the absolute position relative to the container and hide first. when the game ends, show up
JS
select all the DOM needed with idthe initial score is zero, and the time is 10 seconds
get the difficulty from localStorage if have inside or set to medium and also show in the select
When loading the page, the mouse focus on the input right away
When typing in the text, the value of texting compares to the word shown in the DOM. If they match completely, it's time to get a new word and update the score and time.
check the difficulty level before running the updateTime function
and initially load the function
When the time reaches zero, which mean the time is ended, the gameOver function is running
turn the display from none to flex