File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7+ < title > Timer</ title >
8+ </ head >
9+ < body >
10+ < input id ="duration " />
11+ < button id ="start "> Start</ button >
12+ < button id ="pause "> Pause</ button >
13+ < script src ="index.js "> </ script >
14+ </ body >
15+ </ html >
Original file line number Diff line number Diff line change 1+ // ******************************
2+ // What on Earth are Prototypes ******************************
3+
4+ class Timer {
5+ constructor ( durationInput , startButton , pauseButton ) {
6+ this . durationInput = durationInput
7+ this . startButton = startButton
8+ this . pauseButton = pauseButton
9+
10+ // start(){}, Calling the constructor anytime the user clicks on the start button
11+ this . startButton , addEventListener ( 'click' , this . start )
12+ }
13+
14+ start ( ) {
15+ console . log ( 'Time to start the timer!' ) ;
16+ }
17+ }
18+
19+ const durationInput = document . querySelector ( '#duration' )
20+ const startButton = document . querySelector ( '#pause' )
21+ const pauseButton = document . querySelector ( '#pause' )
22+
23+ // Create our instance of the timer and pass in those three elements
24+ const timer = new Timer ( durationInput , startButton , pauseButton )
Original file line number Diff line number Diff line change 1+ ## 19-Prototypes-Classes-And-The-New-Operator
2+
3+ ## 1. 06 Binding Events in a Class
4+
5+ ##
You can’t perform that action at this time.
0 commit comments