1 00:00:00,362 --> 00:00:03,200 Now that we've tried storing values in variables, 2 00:00:03,200 --> 00:00:07,919 let's practice using variables in ways we might while programming with JavaScript. 3 00:00:07,919 --> 00:00:11,419 Earlier I mentioned that the number type in JavaScript allows you to perform 4 00:00:11,419 --> 00:00:12,740 mathematical operations. 5 00:00:13,900 --> 00:00:18,250 Based on what you learned in the last video, try creating two variables and 6 00:00:18,250 --> 00:00:20,540 assign each a different number value. 7 00:00:21,790 --> 00:00:25,992 Once created, use the variable names to add the variables together, and 8 00:00:25,992 --> 00:00:28,310 then print this outcome to the console. 9 00:00:29,720 --> 00:00:30,980 Pause here and give it a try. 10 00:00:33,430 --> 00:00:36,930 If you weren't able to figure it out, don't worry, we'll try it together. 11 00:00:38,510 --> 00:00:42,260 Before we write any new code, let's use the clear command to clean up the console. 12 00:00:43,430 --> 00:00:45,472 That's the word clear followed by parentheses. 13 00:00:48,909 --> 00:00:55,517 First, let's create a variable named number1 and set it equal to 100. 14 00:00:59,438 --> 00:01:04,128 Now, we'll set a variable name number2 to 150. 15 00:01:12,032 --> 00:01:16,607 Next, we'll combine them using the plus sign or 16 00:01:16,607 --> 00:01:21,530 addition operator by typing number1 + number2. 17 00:01:23,824 --> 00:01:27,010 Now when you press Enter, you'll see the result of this equation. 18 00:01:28,050 --> 00:01:29,600 You can even see a preview before. 19 00:01:31,110 --> 00:01:32,360 Nice work. 20 00:01:32,360 --> 00:01:35,210 What do you think might happen if we try adding two strings together? 21 00:01:36,420 --> 00:01:40,397 Try typing "hello" + "fsjs" and press Enter. 22 00:01:49,551 --> 00:01:52,230 We get a combination of the strings without any spaces. 23 00:01:53,390 --> 00:01:55,586 Other data types aren't allowed to do math, but 24 00:01:55,586 --> 00:01:57,310 they come with their own operations. 25 00:01:58,370 --> 00:02:02,779 For instance, when it comes to strings, the plus sign is referred to as 26 00:02:02,779 --> 00:02:08,350 a concatenation operator and is used to combine two or more string values. 27 00:02:08,350 --> 00:02:11,137 Let's try combining variables that store our first and 28 00:02:11,137 --> 00:02:12,919 last names to print our full names. 29 00:02:12,919 --> 00:02:19,810 We'll clear the console again, and I will create a variable named firstName, 30 00:02:23,835 --> 00:02:31,399 Make sure it's a string, And a variable named lastName, 31 00:02:38,062 --> 00:02:40,389 And combine those variables. 32 00:02:45,580 --> 00:02:51,323 And uh-oh, again, we get our names together without a space between. 33 00:02:51,323 --> 00:02:54,930 Concatenation works with exactly what we give it. 34 00:02:54,930 --> 00:03:00,185 Let's add a space between the two names by using one more concatenation operator and 35 00:03:00,185 --> 00:03:02,560 wrapping a space in quotation marks. 36 00:03:13,681 --> 00:03:15,290 There we go, well done. 37 00:03:16,300 --> 00:03:19,536 I've added a link to resources on concatenation and 38 00:03:19,536 --> 00:03:21,674 strings to the teacher's notes. 39 00:03:21,674 --> 00:03:25,297 I'll always encourage you to check the teacher's notes for helpful links that can 40 00:03:25,297 --> 00:03:28,860 further your understanding of the concept we're learning. 41 00:03:28,860 --> 00:03:33,445 You've gotten a glimpse of the power JavaScript gives developers to take input, 42 00:03:33,445 --> 00:03:36,120 compute data, and provide output. 43 00:03:36,120 --> 00:03:37,510 We've only scratched the surface. 44 00:03:38,690 --> 00:03:41,068 Speaking of a surface, in the next video, 45 00:03:41,068 --> 00:03:45,426 we'll have some fun making changes to the presentation layer of a web page with 46 00:03:45,426 --> 00:03:49,010 JavaScript, just like a front-end developer does on the job.