1
00:00:00,200 --> 00:00:01,400
In this video.

2
00:00:01,400 --> 00:00:05,240
Let's begin with the arithmetic operators.

3
00:00:05,240 --> 00:00:11,990
And this includes addition, subtraction, multiplication and division.

4
00:00:12,290 --> 00:00:14,270
Back to Visual Studio code.

5
00:00:14,270 --> 00:00:20,840
Since this is a new concept, I'm going to create a different folder for it and I'm going to copy and

6
00:00:20,840 --> 00:00:25,040
paste this one and rename this one to.

7
00:00:26,360 --> 00:00:27,440
Operators.

8
00:00:29,760 --> 00:00:39,810
And inside here I'm going to remove all the JavaScript code and I'm going to rename this one to JavaScript

9
00:00:39,810 --> 00:00:40,890
operators.

10
00:00:42,710 --> 00:00:43,370
Great.

11
00:00:43,370 --> 00:00:46,100
So now let's open this one.

12
00:00:46,100 --> 00:00:48,800
And mine has opened here.

13
00:00:48,980 --> 00:00:52,520
Let me reopen this as that.

14
00:00:52,520 --> 00:00:54,880
Now we have operators.

15
00:00:54,890 --> 00:00:56,990
So back to JavaScript.

16
00:00:56,990 --> 00:01:02,840
Let me close this and let's begin with the addition operator.

17
00:01:02,930 --> 00:01:08,840
And I'm going to add the comment here to make our life easier as that.

18
00:01:08,840 --> 00:01:14,600
And up here I'm going to add the arithmetic operators.

19
00:01:15,820 --> 00:01:18,790
And let's begin with the addition.

20
00:01:19,060 --> 00:01:23,110
Let's say that you have five apples.

21
00:01:23,290 --> 00:01:26,890
And then you got ten more.

22
00:01:27,130 --> 00:01:31,780
How are you going to transform this one into code?

23
00:01:31,810 --> 00:01:35,890
Meaning we want to find the final result.

24
00:01:36,190 --> 00:01:38,950
So this how is going to work?

25
00:01:39,130 --> 00:01:47,560
We are going to declare a variable and I'm going to use const and I will say apples on hand.

26
00:01:47,980 --> 00:01:50,890
I mean the apples that you have.

27
00:01:51,250 --> 00:01:59,110
Then later on you got ten more and that is apples received.

28
00:02:00,440 --> 00:02:02,610
Is equal to ten.

29
00:02:02,630 --> 00:02:06,850
So how are we going to perform operations on this?

30
00:02:07,240 --> 00:02:08,330
Guys, take note.

31
00:02:08,360 --> 00:02:12,020
We have started thinking like a programmer.

32
00:02:12,840 --> 00:02:15,840
Because we are transforming a sentence.

33
00:02:15,840 --> 00:02:22,260
Like if a person has five apples and then the person got ten more.

34
00:02:22,500 --> 00:02:25,500
How are you going to calculate this using code?

35
00:02:25,500 --> 00:02:27,000
And these are the steps.

36
00:02:27,270 --> 00:02:33,670
So next step is that we need to save the value or the result into a variable.

37
00:02:33,690 --> 00:02:35,910
So you need to be creative.

38
00:02:35,940 --> 00:02:41,450
So here for the variable name, we are going to use descriptive.

39
00:02:41,460 --> 00:02:48,810
So what we're going to be the variable name here is going to be total apples for the variables name.

40
00:02:48,810 --> 00:02:54,840
We don't have right or wrong variable names, but it must be descriptive as we have spoke about.

41
00:02:54,840 --> 00:03:03,240
For this one, we are going to add apples on hand and then we add the apples received.

42
00:03:03,570 --> 00:03:10,740
Now we have the result of this one being assigned to total apples.

43
00:03:10,830 --> 00:03:17,200
So if we console log the total apples, now let's see.

44
00:03:17,200 --> 00:03:18,910
And we have 15.

45
00:03:19,300 --> 00:03:26,530
And if I change this one to something like 90 and JavaScript is going to perform the calculations for

46
00:03:26,530 --> 00:03:28,600
us, save it and let's see.

47
00:03:28,600 --> 00:03:30,250
And we have 100.

48
00:03:30,250 --> 00:03:36,520
And if I change this one to something like this, JavaScript is going to do the calculations for us

49
00:03:36,520 --> 00:03:39,010
and we have it down here.

50
00:03:39,100 --> 00:03:44,800
Then the next type of the arithmetic operator is the subtraction operator.

51
00:03:44,800 --> 00:03:47,740
And for this one it is more descriptive.

52
00:03:47,770 --> 00:03:53,950
So I'll paste it down here as that and it subtract one or more from another.

53
00:03:53,950 --> 00:03:58,690
And even for this we can add more operations inside.

54
00:03:58,690 --> 00:04:01,330
But let's go to the subtraction.

55
00:04:01,720 --> 00:04:08,770
Let's say that there are 100 tickets for a concert and 45 are sold.

56
00:04:08,890 --> 00:04:11,890
Then how many tickets are left?

57
00:04:11,920 --> 00:04:15,190
How are you going to transform this one into code?

58
00:04:15,190 --> 00:04:18,190
And here is a clue or here is an answer.

59
00:04:18,339 --> 00:04:27,370
First of all, I'm going to declare a variable called total ticket and is equal to 100.

60
00:04:27,550 --> 00:04:33,100
Then the ticket sold as concert ticket.

61
00:04:35,550 --> 00:04:39,480
Sold is equal to 45.

62
00:04:39,870 --> 00:04:51,690
Then the final result is going to be the ticket left and is equal to the total ticket minus the ticket

63
00:04:51,690 --> 00:04:52,380
sold.

64
00:04:52,710 --> 00:04:56,370
And if you console log the ticket left.

65
00:04:56,400 --> 00:05:00,750
Let's look inside here and we have 55.

66
00:05:00,780 --> 00:05:03,570
That is the subtraction for you.

67
00:05:03,810 --> 00:05:07,190
Then the next type is the multiplication.

68
00:05:07,200 --> 00:05:12,300
As the name implies, we used to multiply two or more numbers together.

69
00:05:12,540 --> 00:05:21,810
And for this, let me add the question here so that you can think about it and transform that one into

70
00:05:21,810 --> 00:05:22,380
code.

71
00:05:22,380 --> 00:05:33,630
And I will paste it here as if a book cost $20 and someone buys 15, what will be the total cost for

72
00:05:33,630 --> 00:05:34,800
this purchase?

73
00:05:34,800 --> 00:05:38,530
So how are you going to transform this one into code?

74
00:05:38,530 --> 00:05:42,940
And it goes like this const book cost.

75
00:05:43,730 --> 00:05:45,920
Is equal to 20.

76
00:05:46,740 --> 00:05:55,080
Then the books bought and that is the books bought is equal to 15.

77
00:05:55,350 --> 00:06:00,780
Therefore, we are going to declare total cost.

78
00:06:01,560 --> 00:06:04,710
Which is equal to the book cost.

79
00:06:04,740 --> 00:06:08,760
Then multiply by the books bought.

80
00:06:09,330 --> 00:06:16,830
And if we save this and check the total cost, we have 300.

81
00:06:17,190 --> 00:06:17,540
Cool.

82
00:06:17,610 --> 00:06:18,230
Right.

83
00:06:18,240 --> 00:06:22,190
And the next one is the division operator.

84
00:06:22,200 --> 00:06:24,590
And I will paste it here.

85
00:06:24,600 --> 00:06:32,490
And let me give you the question that we are going to use to transform into code, and I'm going to

86
00:06:32,490 --> 00:06:35,370
paste it here as that.

87
00:06:36,490 --> 00:06:47,760
Great if there are 200 pages in a book and you read 40 pages per day, you will finish in how many days?

88
00:06:47,770 --> 00:06:50,410
And that is the five days, right.

89
00:06:50,440 --> 00:06:56,140
So how are you going to transform this one into code?

90
00:06:56,170 --> 00:06:58,340
So let's see the logic.

91
00:06:58,360 --> 00:07:03,520
First of all, read the question and then analyze the variables names.

92
00:07:03,520 --> 00:07:13,600
And that is, if there are 200 pages, meaning total pages is equal to 200, then the next step is that

93
00:07:13,630 --> 00:07:17,070
if you read 20 pages per day.

94
00:07:17,110 --> 00:07:22,690
So here we are going to transform that one as pages.

95
00:07:23,390 --> 00:07:27,830
Per day, which is equal to 40.

96
00:07:28,370 --> 00:07:32,690
Therefore, how many days that you think you can finish.

97
00:07:32,690 --> 00:07:38,560
So it's going to be as const days to finish.

98
00:07:38,570 --> 00:07:46,880
As you can see here that my variable names are descriptive, so it's going to be the total pages divided

99
00:07:46,880 --> 00:07:50,960
by the pages per day with this one.

100
00:07:50,960 --> 00:08:02,090
If I check this to finish and we have five days to finish, then the next type is the module operator

101
00:08:02,090 --> 00:08:05,720
and it's sometimes called the remainder.

102
00:08:05,720 --> 00:08:08,600
So over here I'm going to paste that.

103
00:08:08,600 --> 00:08:10,400
And this is a symbol.

104
00:08:10,670 --> 00:08:16,250
It divides a number by another and retains the remainder.

105
00:08:16,280 --> 00:08:25,040
When I say what is a remainder of three divided by 4 or 4 divided by three.

106
00:08:25,190 --> 00:08:31,980
So over here, let me give you the scenario that we are going to transform into code.

107
00:08:32,429 --> 00:08:42,179
So here if ten people are at a party and there are three pieces, each person gets three slices and

108
00:08:42,179 --> 00:08:47,510
how many slices will be left and that is one slice will be left over.

109
00:08:47,520 --> 00:08:52,410
So let's go ahead and transform this one into code.

110
00:08:52,410 --> 00:08:57,210
And it goes like this const, how many people are the party?

111
00:08:57,240 --> 00:09:05,910
So we're going to be as people at the party and they are ten people, so it's going to be as ten and

112
00:09:05,910 --> 00:09:08,100
how many pizzas are at the party?

113
00:09:08,100 --> 00:09:12,330
So here as pizzas at party.

114
00:09:13,870 --> 00:09:15,720
Is equal to three.

115
00:09:15,930 --> 00:09:17,700
Then how many were left?

116
00:09:17,700 --> 00:09:23,490
So here I will say const slice left over.

117
00:09:24,420 --> 00:09:28,290
Which is equal to the people at the party.

118
00:09:28,560 --> 00:09:34,710
Then the percentage sign which represents the module and pizzas at the party.

119
00:09:34,980 --> 00:09:42,960
So if I console log slice left over, we have one left.

120
00:09:43,540 --> 00:09:48,800
And the next type is called the increment and decrement.

121
00:09:48,820 --> 00:09:57,850
So let me paste the next type here called increment and decrement, meaning we are going to increase

122
00:09:57,880 --> 00:09:59,860
a value by one.

123
00:09:59,980 --> 00:10:09,970
So over here, let me paste the question here, which says that if a website has 1000 views and then

124
00:10:09,970 --> 00:10:14,960
one person visit the website now has how many views?

125
00:10:14,980 --> 00:10:18,830
That is 1001.

126
00:10:18,850 --> 00:10:22,450
So how are we going transform this one into code?

127
00:10:22,450 --> 00:10:24,250
And it goes like this.

128
00:10:24,280 --> 00:10:27,430
Const let's deduce what is inside this.

129
00:10:27,430 --> 00:10:31,240
And that is if a website has 1000 views.

130
00:10:31,240 --> 00:10:37,510
So here we are going to represent this one as the current website views.

131
00:10:37,510 --> 00:10:44,480
So it's going to be as current views is equal to 1000.

132
00:10:44,900 --> 00:10:53,900
Then if I want to increase by one, I'm going to use the current views then plus plus.

133
00:10:54,020 --> 00:11:02,150
So this is what we call the decrement with this one, if I receive it, as you can see, we have an

134
00:11:02,150 --> 00:11:02,690
error.

135
00:11:02,690 --> 00:11:04,640
I mean, tell me the issue here.

136
00:11:04,670 --> 00:11:12,950
The problem here is that we are reassigning a value that has been declared with const.

137
00:11:13,130 --> 00:11:17,690
Therefore we cannot reassign or update the value.

138
00:11:17,780 --> 00:11:22,190
So for this case we are going to use let save it.

139
00:11:22,190 --> 00:11:34,220
And now let's look at the current views and we have 1001 and this is the same as this which is plus

140
00:11:34,220 --> 00:11:35,690
equal to one.

141
00:11:36,110 --> 00:11:38,730
So that syntax is the same as this.

142
00:11:38,730 --> 00:11:47,540
So with this one, if I check the current views, I still see the result and for this I can increase

143
00:11:47,540 --> 00:11:48,500
by any value.

144
00:11:48,500 --> 00:11:55,220
So for this one we are increasing by ten if I save it and check the result.

145
00:11:55,250 --> 00:11:57,800
Here we have 1010.

146
00:11:58,340 --> 00:11:58,880
Right.

147
00:11:58,880 --> 00:12:01,910
That is the increment for you.

148
00:12:02,150 --> 00:12:05,240
And the last type is called the decrement.

149
00:12:05,240 --> 00:12:14,480
So I'm going to paste the comment here and this one is used to decrease by one and we have different

150
00:12:14,480 --> 00:12:18,020
alternative where we can decrease by any amount.

151
00:12:18,020 --> 00:12:26,420
So for this one, let me change this one to plus plus, if a basket player has 20 points and a point

152
00:12:26,420 --> 00:12:29,600
is taken away, they now have how many points?

153
00:12:29,630 --> 00:12:30,890
19 point.

154
00:12:30,890 --> 00:12:33,440
So let's transform this one into code.

155
00:12:33,440 --> 00:12:37,130
So here let and we're going to say basket.

156
00:12:38,490 --> 00:12:39,750
Ballpoint.

157
00:12:42,430 --> 00:12:44,800
And is equal to 20.

158
00:12:44,830 --> 00:12:51,040
And here we are going to decrease by one and that is minus.

159
00:12:51,040 --> 00:12:53,990
Minus as that with this one.

160
00:12:54,010 --> 00:13:03,820
If I check the basketball point, we have 19 and for this one it is same as minus equal to one.

161
00:13:04,060 --> 00:13:06,060
So the same as before.

162
00:13:06,070 --> 00:13:08,620
If you check it out and we have the same result.

163
00:13:08,620 --> 00:13:11,980
And for this I can decrease by any value.

164
00:13:11,980 --> 00:13:15,910
And let's see, we have -980.

165
00:13:16,180 --> 00:13:16,930
Great.

166
00:13:16,930 --> 00:13:21,000
So these are the examples of the arithmetic operators.

167
00:13:21,010 --> 00:13:22,720
Let's continue in the next video.

