1
00:00:02,160 --> 00:00:05,150
Now that we covered some important basics

2
00:00:05,150 --> 00:00:07,920
about variables, I want you to practice

3
00:00:07,920 --> 00:00:09,780
what we learnt up to this point.

4
00:00:09,780 --> 00:00:14,400
And I want you to take this 32, value you this number

5
00:00:14,400 --> 00:00:18,410
and store it in a variable instead of using it here

6
00:00:18,410 --> 00:00:20,100
in the place where we need it.

7
00:00:20,100 --> 00:00:22,140
Instead, store it in a variable

8
00:00:22,140 --> 00:00:23,820
at the beginning of our script,

9
00:00:23,820 --> 00:00:26,860
and then use that variable down here.

10
00:00:26,860 --> 00:00:29,390
Maybe also we'll use two alerts

11
00:00:29,390 --> 00:00:32,049
that then work with that variable

12
00:00:32,049 --> 00:00:35,080
to make adding that variable a bit more useful.

13
00:00:35,080 --> 00:00:36,380
Now, one important hint,

14
00:00:36,380 --> 00:00:39,230
which you will need for creating this variable,

15
00:00:39,230 --> 00:00:42,610
this value 32 could be a age,

16
00:00:42,610 --> 00:00:46,640
but that might matter for picking a proper variable name.

17
00:00:46,640 --> 00:00:50,070
That's my challenge for you, add this new variable,

18
00:00:50,070 --> 00:00:53,190
I'll give you a short pause, to pause the video

19
00:00:53,190 --> 00:00:54,330
and try this on your own

20
00:00:54,330 --> 00:00:56,080
thereafter, we'll do this together.

21
00:01:00,410 --> 00:01:02,490
So, did you succeed?

22
00:01:02,490 --> 00:01:03,640
Let's do this together.

23
00:01:04,860 --> 00:01:07,370
We wanna create a second variable.

24
00:01:07,370 --> 00:01:09,910
And I mentioned that you should add it somewhere

25
00:01:09,910 --> 00:01:11,750
at the beginning of this script,

26
00:01:11,750 --> 00:01:15,650
though I wanna emphasize that you can add the variables

27
00:01:15,650 --> 00:01:17,830
anywhere in your script.

28
00:01:17,830 --> 00:01:20,490
You can add them at the end,

29
00:01:20,490 --> 00:01:23,820
in between and at the beginning.

30
00:01:23,820 --> 00:01:25,800
Now at the end doesn't make sense here

31
00:01:25,800 --> 00:01:27,950
since I wanna use it in my code.

32
00:01:27,950 --> 00:01:31,050
So adding the variable thereafter would not work

33
00:01:31,050 --> 00:01:34,083
since the code is executed from top to bottom.

34
00:01:34,980 --> 00:01:38,590
Adding it in the middle or maybe a right before I plan

35
00:01:38,590 --> 00:01:40,020
on using it would work.

36
00:01:40,020 --> 00:01:41,640
But since my instruction for you

37
00:01:41,640 --> 00:01:44,170
was to add it at the beginning of the script,

38
00:01:44,170 --> 00:01:48,980
I wanna add it here or maybe after greeting text, up to you.

39
00:01:48,980 --> 00:01:50,963
I will add it right at the top.

40
00:01:51,980 --> 00:01:55,440
Now we did learn that we can now add a new variable

41
00:01:55,440 --> 00:01:57,420
with the let keyword.

42
00:01:57,420 --> 00:01:59,600
That's what we used before as well.

43
00:01:59,600 --> 00:02:02,070
And then we need to pick a name.

44
00:02:02,070 --> 00:02:04,080
That name as you learnt is up to you,

45
00:02:04,080 --> 00:02:07,870
but has to follow certain rules and conventions

46
00:02:07,870 --> 00:02:09,560
and which name we choose

47
00:02:09,560 --> 00:02:13,600
depends on what that value represents.

48
00:02:13,600 --> 00:02:17,620
And here, I'm assuming it represents my age.

49
00:02:17,620 --> 00:02:20,243
So I will name the variable age.

50
00:02:21,220 --> 00:02:24,680
Now that's my name and the interesting thing about this name

51
00:02:24,680 --> 00:02:27,720
of course is that, unlike greeting text,

52
00:02:27,720 --> 00:02:31,380
this has no capital characters inside of it

53
00:02:31,380 --> 00:02:33,420
because that's not a must do.

54
00:02:33,420 --> 00:02:36,610
It's only a must to do if your variable name

55
00:02:36,610 --> 00:02:39,480
actually consists of multiple words,

56
00:02:39,480 --> 00:02:41,110
sometimes you might need that

57
00:02:41,110 --> 00:02:44,270
to properly describe the value.

58
00:02:44,270 --> 00:02:48,640
In the case of age, the word age is enough to describe that.

59
00:02:48,640 --> 00:02:51,460
Guess what, a number that represents an age

60
00:02:51,460 --> 00:02:53,430
is stored in there.

61
00:02:53,430 --> 00:02:56,800
We could of course also choose user age instead,

62
00:02:56,800 --> 00:03:00,570
and then write it like this, but that's totally optional.

63
00:03:00,570 --> 00:03:02,687
It would also be fine though,

64
00:03:03,540 --> 00:03:07,580
but here I'll go for age and then store 32 as a value.

65
00:03:07,580 --> 00:03:09,790
And I will also add that semi-colon,

66
00:03:09,790 --> 00:03:12,940
since that is the style I will use in this course,

67
00:03:12,940 --> 00:03:16,923
and that is a style you will see a lot out there in general.

68
00:03:18,360 --> 00:03:22,760
And now that this variable was created, we can use it.

69
00:03:22,760 --> 00:03:25,510
We can use it here for the alert

70
00:03:25,510 --> 00:03:29,240
and output age by referencing it.

71
00:03:29,240 --> 00:03:31,920
So by basically telling JavaScript

72
00:03:31,920 --> 00:03:35,830
and therefore the browser, "Hey, please show an alert"

73
00:03:35,830 --> 00:03:37,660
and the content of the alert

74
00:03:37,660 --> 00:03:40,500
should be the value stored in age.

75
00:03:40,500 --> 00:03:42,823
That's what we're telling JavaScript here.

76
00:03:43,910 --> 00:03:46,770
And of course we can also output multiple alerts

77
00:03:46,770 --> 00:03:48,483
for this age like this.

78
00:03:49,950 --> 00:03:54,950
And if I save that, if I reload this page, I get high IMAX,

79
00:03:56,300 --> 00:03:59,710
twice, and then that changed text.

80
00:03:59,710 --> 00:04:04,710
And then there after, I get my age, 32 being output twice.

81
00:04:05,770 --> 00:04:07,650
And of course we could now also change

82
00:04:07,650 --> 00:04:09,320
that variable somewhere

83
00:04:09,320 --> 00:04:12,950
and assign a new value again with the equal sign,

84
00:04:12,950 --> 00:04:14,950
as we're doing it with creating text.

85
00:04:14,950 --> 00:04:16,589
And that's something you can do,

86
00:04:16,589 --> 00:04:19,440
but not something you need to do here.

87
00:04:19,440 --> 00:04:22,543
And that's now another variable introduced.

