1
00:00:00,120 --> 00:00:03,630
More operators to come in this lesson, and they are important.

2
00:00:03,660 --> 00:00:06,660
So we are going to spend a little bit more time on operators.

3
00:00:06,970 --> 00:00:08,820
So we saw not operators.

4
00:00:09,030 --> 00:00:13,230
And there's also increment, which is a shorthand method for operators.

5
00:00:13,440 --> 00:00:19,770
And we could also update our assignment operators by using the plus equal sign instead of just the equals

6
00:00:19,770 --> 00:00:20,880
sign equal plus.

7
00:00:21,120 --> 00:00:23,640
And I'm going to show you some examples of these coming up.

8
00:00:24,060 --> 00:00:29,430
So we saw it with assignment operators where we could set a variable, we could declare a variable and

9
00:00:29,430 --> 00:00:31,850
we can sign a value using that equal sign.

10
00:00:32,130 --> 00:00:34,160
So there's a little bit more we can do as well.

11
00:00:34,920 --> 00:00:41,420
And Mozilla has a great and Mozilla has a document on this, of course, for the assignment operator.

12
00:00:41,430 --> 00:00:42,670
So there's the equal sign.

13
00:00:42,690 --> 00:00:44,370
So we are familiar with that one.

14
00:00:44,640 --> 00:00:47,940
And we're also looking at how we can equal it.

15
00:00:47,940 --> 00:00:50,870
And then we can have another formula here.

16
00:00:50,880 --> 00:00:58,410
So another arithmetic or operator there, and they've got the full list of different types of assignment

17
00:00:58,410 --> 00:00:59,010
operators.

18
00:00:59,020 --> 00:01:04,410
So we've got addition, assignment, subtraction, assignment, multiplication, division and so on.

19
00:01:04,690 --> 00:01:07,480
There's a whole bunch of operators that are available for you.

20
00:01:07,770 --> 00:01:10,680
So the typical assignment operator is just the equal sign.

21
00:01:10,830 --> 00:01:16,230
But we can also equal and equal so that all of them will equal that one value.

22
00:01:16,230 --> 00:01:22,980
So X, Y and Z are all going to be equivalent to the same value because then at the end is equal to

23
00:01:22,980 --> 00:01:23,530
25.

24
00:01:24,210 --> 00:01:28,090
There's also a shorthand, which is the plus equal sign.

25
00:01:28,290 --> 00:01:35,190
So this is equivalent to X equals X plus Y, or you could do X plus equal Y.

26
00:01:35,190 --> 00:01:37,140
So that's a shorthand format for doing that.

27
00:01:37,950 --> 00:01:40,320
And they've got some examples here of those.

28
00:01:40,770 --> 00:01:44,370
And we can also do a number plus a string.

29
00:01:44,550 --> 00:01:46,500
And this is just concatenation.

30
00:01:46,500 --> 00:01:51,240
So JavaScript takes care of the data type X equals X minus wire.

31
00:01:51,240 --> 00:01:56,970
We could do X minus equal Y, so it's the same thing and some additional examples of that.

32
00:01:56,970 --> 00:02:00,350
And of course we can't subtract strings as we saw before.

33
00:02:00,720 --> 00:02:03,420
So that's where we get that nine again.

34
00:02:03,420 --> 00:02:05,450
So nine not a number.

35
00:02:05,460 --> 00:02:11,610
There's also multiplication, same format and also division where we can do the assignment division

36
00:02:11,610 --> 00:02:12,840
and shorten that as well.

37
00:02:12,840 --> 00:02:16,730
And that will definitely keep you busy trying out all of those examples.

38
00:02:16,860 --> 00:02:22,230
So we did see that we did have a shorthand method and we also have the ability to increment.

39
00:02:22,230 --> 00:02:24,210
So plus plus, minus minus.

40
00:02:24,450 --> 00:02:32,280
And that's equal to X equals X plus one or X equals X minus one, comma B comma C comedy.

41
00:02:32,430 --> 00:02:39,720
But we can also assign values as we're declaring them and we can assign multiple values at one time

42
00:02:39,720 --> 00:02:40,880
to variables.

43
00:02:40,890 --> 00:02:47,910
So now we have an interesting challenge for you in this lesson and that's to take the code and determine

44
00:02:47,910 --> 00:02:49,800
what the output of the code will be.

45
00:02:49,830 --> 00:02:52,020
So what's going to be output in the console?

46
00:02:52,230 --> 00:02:57,300
So try out some of the different operators, try out some of the different combinations and see what

47
00:02:57,300 --> 00:03:02,400
you can get as the solution to this code number is going to be equal to five.

48
00:03:02,400 --> 00:03:10,410
Second number is going to be equal to ten variable A equals five plus five.

49
00:03:10,830 --> 00:03:13,830
We're going to see that A has a value of ten, of course.

50
00:03:14,160 --> 00:03:21,720
And now if we take A and if we equal it to a plus ten, then that's going to return back the value of

51
00:03:21,720 --> 00:03:22,890
eight at twenty.

52
00:03:23,100 --> 00:03:28,950
Or we could do a and plus equals another ten.

53
00:03:28,950 --> 00:03:30,660
And what do you think the value of A is going to be?

54
00:03:30,990 --> 00:03:32,920
If you said thirty, you are correct.

55
00:03:33,240 --> 00:03:35,510
So do try that out and play around with it a little bit.

56
00:03:36,090 --> 00:03:37,560
Let's finish up this.

57
00:03:37,560 --> 00:03:42,870
So we saw that we can do these different assignment values and we can also increment eight.

58
00:03:43,200 --> 00:03:50,430
So now if we return back a we get a value of thirty one and notice that the response is still at thirty

59
00:03:50,550 --> 00:03:55,380
because we're responding back to the value of a so we haven't done the increment quite yet.

60
00:03:55,620 --> 00:03:56,610
And that's the same thing.

61
00:03:56,610 --> 00:03:59,940
If we do a minus minus we're still at thirty one.

62
00:04:00,060 --> 00:04:05,820
But when we look at the value of a it's thirty, so keep that in mind that we're always seen that as

63
00:04:05,820 --> 00:04:06,630
the response.

64
00:04:06,870 --> 00:04:14,220
So if we were actually assigning a value of whatever a minus minus is equal to, we would still be holding

65
00:04:14,220 --> 00:04:20,340
that initial value before we did the actual subtraction and we're going to increment it by one and then

66
00:04:20,340 --> 00:04:26,100
take the second number and we're going to decrease it by one and then we're going to create another

67
00:04:26,100 --> 00:04:34,190
variable and assigning a value of first num plus second num, and that's going to be the value of total

68
00:04:34,500 --> 00:04:38,250
and first of all, console logout, whatever the value of total is.

69
00:04:38,490 --> 00:04:46,590
And we're going to equal that to five hundred plus one hundred divided by five plus total.

70
00:04:46,590 --> 00:04:53,100
So also let's logout the value of total and you can see that we're being returned back fifteen for the

71
00:04:53,100 --> 00:04:53,630
first one.

72
00:04:53,850 --> 00:04:57,600
So what's happening here is that first number is five second numbers, ten.

73
00:04:57,810 --> 00:04:59,850
We're adding one to first number, so.

74
00:04:59,880 --> 00:05:05,250
Getting back six and then we're subtracting one from second number, so we're getting six plus nine,

75
00:05:05,550 --> 00:05:08,800
and that's leaving our total of 15.

76
00:05:08,910 --> 00:05:15,030
So if you take those in first number, we've got six second number, we've got nine.

77
00:05:15,120 --> 00:05:16,560
And that's where we get in the 15.

78
00:05:17,130 --> 00:05:22,750
The next one, 500 plus one hundred divided by five plus total.

79
00:05:22,860 --> 00:05:29,490
So one hundred divided by five is twenty five hundred plus twenty plus the value of total.

80
00:05:29,490 --> 00:05:35,580
And we know the value of total is 15, then we get a total of 335.

81
00:05:35,820 --> 00:05:40,070
So that's how we can work out the calculations for this particular assignment.
