1
00:00:00,090 --> 00:00:05,370
This lesson, we're going to set up a timer, we need to add in a few variables that can hold a start

2
00:00:05,370 --> 00:00:10,530
time and an end time so we can call it start time and end time.

3
00:00:11,220 --> 00:00:17,680
So that's setting up those two global variables that we can add in start and end times into.

4
00:00:17,970 --> 00:00:22,350
So now when we hit Play the game, we want to grab the current time.

5
00:00:22,650 --> 00:00:26,900
And with JavaScript Dete, we are getting the system time.

6
00:00:27,150 --> 00:00:32,910
So this is whatever your browser, whatever your computer system time is, this is the date that it's

7
00:00:32,910 --> 00:00:33,400
going to get.

8
00:00:33,780 --> 00:00:39,780
So let's get our late date and we're going to equal that to new date using the same date object that

9
00:00:39,780 --> 00:00:46,310
we used in the earlier lessons, our start time taking our date object and getting time.

10
00:00:46,320 --> 00:00:52,760
So this returns back that Unix time stamp, which is a universal time stamp and we can console log out

11
00:00:52,770 --> 00:00:55,470
that start time so that we can see it within the console.

12
00:00:55,590 --> 00:00:58,500
And I'm also going to update the button text.

13
00:00:58,740 --> 00:01:00,630
So it's no longer going to be start.

14
00:01:00,780 --> 00:01:02,040
It's going to be done.

15
00:01:02,040 --> 00:01:04,910
So we're going to update that in our text to done.

16
00:01:04,950 --> 00:01:05,780
So let's try that out.

17
00:01:05,820 --> 00:01:07,170
So make this a little bit smaller.

18
00:01:07,200 --> 00:01:14,250
Refresh the page and we should see that this button should change to be done as well as we should see

19
00:01:14,550 --> 00:01:19,020
the random value there as well as the random time value.

20
00:01:19,020 --> 00:01:19,590
So let's try that.

21
00:01:20,100 --> 00:01:21,990
So this is the random start time.

22
00:01:21,990 --> 00:01:27,370
And as we can see, that this button is no longer functioning because we are listening for a start.

23
00:01:27,570 --> 00:01:32,670
So once the entire tax changes, even though we still have the same a button present, we didn't have

24
00:01:32,670 --> 00:01:33,450
to hide the button.

25
00:01:33,460 --> 00:01:34,460
So a different button.

26
00:01:34,620 --> 00:01:40,500
All we did is update that inner text, and that gives us the ability to run different functionality

27
00:01:40,500 --> 00:01:43,490
on that same event listener with the same button element.

28
00:01:43,770 --> 00:01:48,290
So when we refresh it, you're going to see that this time has actually advanced.

29
00:01:48,630 --> 00:01:54,720
So this is a value that we can get and we can check to see the difference between milliseconds.

30
00:01:54,960 --> 00:02:00,010
So we're recording the start time and next we need to record the end time.

31
00:02:00,420 --> 00:02:06,870
So this is what the user is going to press when they're done typing and this is where we're going to

32
00:02:06,870 --> 00:02:08,430
do all of our calculations.

33
00:02:09,120 --> 00:02:10,590
So try that one more time.

34
00:02:10,950 --> 00:02:16,020
When the player pluses start, then it enables the ability to type in the text area.

35
00:02:16,170 --> 00:02:20,520
And the idea is that they type exactly what they see.

36
00:02:20,940 --> 00:02:27,480
And then we're going to calculate out how accurate they were, as well as how quickly they were able

37
00:02:27,480 --> 00:02:29,460
to type that string.

38
00:02:29,970 --> 00:02:37,440
So that's all still to come in the next lesson, go ahead and add in the start time and start time functionality.

39
00:02:37,560 --> 00:02:40,600
And coming up next, we're going to add in the gameplay.

40
00:02:40,740 --> 00:02:41,550
So that's still to come.
