File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212 < div class ="main ">
1313 < h1 > Simon Says</ h1 >
14- < h2 id ="level "> Ready when you are.</ h2 >
14+ < h2 id ="level "> Press any key to start</ h2 >
15+ < h3 id ="score "> Score: 0</ h3 >
1516
1617 < div class ="container ">
1718 < div class ="btn red " id ="red "> </ div >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ let level = 0;
66let started = false ;
77
88let h2 = document . querySelector ( "#level" ) ;
9+ let scoreDisplay = document . querySelector ( "#score" ) ;
910
1011document . addEventListener ( "keypress" , function ( ) {
1112 if ( ! started ) {
@@ -19,6 +20,9 @@ function nextlevel() {
1920 level ++ ;
2021
2122 h2 . innerText = "Level " + level ;
23+ score = level - 1 ;
24+ scoreDisplay . innerText = "Score: " + score ;
25+
2226
2327 let randColor = colors [ Math . floor ( Math . random ( ) * 4 ) ] ;
2428 gameSeq . push ( randColor ) ;
@@ -55,6 +59,8 @@ function checkAnswer(index) {
5559 }
5660 } else {
5761 h2 . innerText = "Game Over! Press any key to restart" ;
62+ scoreDisplay . innerText = "Score: " + score ;
63+
5864 document . body . style . backgroundColor = "red" ;
5965
6066 setTimeout ( ( ) => {
You can’t perform that action at this time.
0 commit comments