File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -37,4 +37,41 @@ function displayWord() {
37
37
}
38
38
}
39
39
40
+ // Update the wrong letters
41
+ function updateWrongLettersEl ( ) { }
42
+
43
+ // Show notification
44
+ function showNotification ( ) {
45
+ notification . classList . add ( "show" ) ;
46
+
47
+ setTimeout ( ( ) => {
48
+ notification . classList . remove ( "show" ) ;
49
+ } , 2000 ) ;
50
+ }
51
+
52
+ // Key down letter press
53
+ window . addEventListener ( "keydown" , e => {
54
+ if ( e . keyCode >= 65 && e . keyCode <= 90 ) {
55
+ const letter = e . key ;
56
+
57
+ if ( selectedWord . includes ( letter ) ) {
58
+ if ( ! correctLetters . includes ( letter ) ) {
59
+ correctLetters . push ( letter ) ;
60
+
61
+ displayWord ( ) ;
62
+ } else {
63
+ showNotification ( ) ;
64
+ }
65
+ } else {
66
+ if ( ! wrongLetters . includes ( letter ) ) {
67
+ wrongLetters . push ( letter ) ;
68
+
69
+ updateWrongLettersEl ( ) ;
70
+ } else {
71
+ showNotification ( ) ;
72
+ }
73
+ }
74
+ }
75
+ } ) ;
76
+
40
77
displayWord ( ) ;
You can’t perform that action at this time.
0 commit comments