1
00:00:02,810 --> 00:00:04,510
Mathematical operations

2
00:00:04,510 --> 00:00:06,580
aren't everything though.

3
00:00:06,580 --> 00:00:08,780
We can also work with strings.

4
00:00:08,780 --> 00:00:12,070
So with text in our JavaScript code.

5
00:00:12,070 --> 00:00:14,490
And I want to show this, as well.

6
00:00:14,490 --> 00:00:17,190
Here, I'm logging a value again,

7
00:00:17,190 --> 00:00:21,940
but now I'll log the result of adding two strings together.

8
00:00:21,940 --> 00:00:25,350
Let's say "Max" and then "Schwarzmüller,"

9
00:00:25,350 --> 00:00:26,833
which is my last name.

10
00:00:28,950 --> 00:00:31,150
Now here, I'm using the plus operator,

11
00:00:31,150 --> 00:00:34,010
but I'm not using it on numbers as I did it before,

12
00:00:34,010 --> 00:00:35,713
but instead on strings,

13
00:00:37,120 --> 00:00:38,420
and that will work.

14
00:00:38,420 --> 00:00:42,870
If I save this, you see this as a result.

15
00:00:42,870 --> 00:00:45,830
The strings have been concatenated.

16
00:00:45,830 --> 00:00:47,233
That's how we call this.

17
00:00:48,920 --> 00:00:51,740
You can use the plus operator on strings

18
00:00:51,740 --> 00:00:54,053
to combine them into one string.

19
00:00:55,340 --> 00:00:59,490
Now, here we don't have any blank or white space

20
00:00:59,490 --> 00:01:02,440
between these two words that have been combined

21
00:01:02,440 --> 00:01:06,020
because we didn't add any here in this operation.

22
00:01:06,020 --> 00:01:07,470
If we would want one,

23
00:01:07,470 --> 00:01:09,983
we would have to add one like this maybe.

24
00:01:11,930 --> 00:01:14,630
And that's how we then would get a blank

25
00:01:14,630 --> 00:01:16,793
in that final string as well.

26
00:01:17,910 --> 00:01:21,560
So you can use the plus operator on strings as well

27
00:01:21,560 --> 00:01:23,893
to concatenate those strings.

28
00:01:25,680 --> 00:01:29,840
You can't however, use the minus operator.

29
00:01:29,840 --> 00:01:33,230
So maybe you would think that this could work

30
00:01:33,230 --> 00:01:36,850
and it should maybe return "M" as a result,

31
00:01:36,850 --> 00:01:39,780
but that is actually not what will happen.

32
00:01:39,780 --> 00:01:42,770
Instead, we get NaN as a result,

33
00:01:42,770 --> 00:01:45,180
and that's now not a special text,

34
00:01:45,180 --> 00:01:49,620
but instead, this is a special type built into JavaScript,

35
00:01:49,620 --> 00:01:52,570
which means "not a number."

36
00:01:52,570 --> 00:01:54,120
And you get this type

37
00:01:54,120 --> 00:01:57,430
whenever you perform a mathematical operation

38
00:01:57,430 --> 00:02:01,520
on values where JavaScript then is not able

39
00:02:01,520 --> 00:02:04,623
to yield a number as a result.

40
00:02:05,570 --> 00:02:08,810
And in case of the plus operator, there is an exception.

41
00:02:08,810 --> 00:02:11,510
This is allowed to work on strings,

42
00:02:11,510 --> 00:02:14,890
but for minus, the times operator,

43
00:02:14,890 --> 00:02:18,480
the division operator, and the modulus operator,

44
00:02:18,480 --> 00:02:22,620
all these operators can really only be used on numbers

45
00:02:22,620 --> 00:02:24,663
and not on strings.

46
00:02:25,640 --> 00:02:28,830
But concatenating strings is a common task

47
00:02:28,830 --> 00:02:31,620
and therefore, something you should know.

48
00:02:31,620 --> 00:02:33,350
And again, just as before,

49
00:02:33,350 --> 00:02:36,650
here, I'm doing it in that place.

50
00:02:36,650 --> 00:02:38,880
I am not using any variables.

51
00:02:38,880 --> 00:02:39,870
Of course,

52
00:02:39,870 --> 00:02:43,260
we could store these individual strings in variables

53
00:02:43,260 --> 00:02:45,580
and then combine these variables,

54
00:02:45,580 --> 00:02:49,290
or also store the result of this in a variable,

55
00:02:49,290 --> 00:02:51,003
and then use that variable.

56
00:02:51,950 --> 00:02:53,790
I'm just not doing that here

57
00:02:53,790 --> 00:02:56,370
because I'm not using these values

58
00:02:56,370 --> 00:03:00,370
or the result of this concatenation anywhere else

59
00:03:00,370 --> 00:03:01,253
in this code.

