1 00:00:00,900 --> 00:00:02,040 Welcome back everybody. 2 00:00:02,040 --> 00:00:06,870 All right so I'm just going to go ahead and actually get rid of this second paragraph tag right here. 3 00:00:06,900 --> 00:00:12,630 It's pretty simple and I'll just go ahead and get rid of that too here so and we'll test everything 4 00:00:12,660 --> 00:00:14,830 and everything still works OK. 5 00:00:14,850 --> 00:00:20,160 Now in this Tauriel what I'm going to do is I'm going to talk to you about something called the variables. 6 00:00:20,160 --> 00:00:27,480 Now I've told you that the function is like a box of code and that box of code will do something. 7 00:00:27,480 --> 00:00:35,030 But if you can imagine a box a code with a whole bunch of other boxes that hold certain values. 8 00:00:35,040 --> 00:00:35,570 OK. 9 00:00:35,730 --> 00:00:38,810 And these values don't necessarily run code. 10 00:00:39,000 --> 00:00:41,930 All they do is they're like numbers and names or something like that. 11 00:00:41,940 --> 00:00:42,470 OK. 12 00:00:42,570 --> 00:00:47,280 Now variables are really important and there are like a box of information really so you have the function 13 00:00:47,280 --> 00:00:53,520 which is a box that does something and the variable is the box of information and variables are super 14 00:00:53,520 --> 00:00:58,290 important because they can again be names they can be numbers or they can be a whole bunch of different 15 00:00:58,290 --> 00:00:59,150 types of data. 16 00:00:59,160 --> 00:01:00,050 Essentially what it is. 17 00:01:00,060 --> 00:01:00,640 Right. 18 00:01:00,660 --> 00:01:04,000 So first thing we're going to do in order to actually call the variable. 19 00:01:04,110 --> 00:01:06,650 All we need to do is type in var OK. 20 00:01:06,810 --> 00:01:13,080 And this var here is the center for variable and javascript's actually unique in that you don't have 21 00:01:13,080 --> 00:01:15,100 to specify the type of variable. 22 00:01:15,120 --> 00:01:16,890 So there's different kinds of variables. 23 00:01:16,890 --> 00:01:20,100 There is something called a boolean variable which is true or false. 24 00:01:20,100 --> 00:01:25,600 There's a integer variable which is numbers and their string variables which is character. 25 00:01:25,600 --> 00:01:28,410 So if you want to make a string variable. 26 00:01:28,410 --> 00:01:31,170 For example it would be like my name. 27 00:01:31,170 --> 00:01:37,830 You can say your name anybody's name but what you couldn't do is you couldn't put a name inside an integer 28 00:01:37,830 --> 00:01:41,610 variable or an int variable because integers are the only numbers. 29 00:01:41,610 --> 00:01:46,920 There's no characters allowed and you couldn't put a number inside a boolean variable cause a booleans 30 00:01:46,930 --> 00:01:48,180 will end true or false. 31 00:01:48,180 --> 00:01:55,170 Now all we have to do in javascript is call the name so we can type in variable name just like this. 32 00:01:55,230 --> 00:01:55,830 And there we go. 33 00:01:55,830 --> 00:02:00,960 So now we have a variable that's all it is and we can have hundreds of these variables in fact if you're 34 00:02:00,960 --> 00:02:07,410 making games or apps you generally have a lot of variables with with your program here and that's one 35 00:02:07,410 --> 00:02:09,440 thing when you're learning about programming. 36 00:02:09,510 --> 00:02:15,230 You see examples with two three four and maybe on the outside chance 10 variables. 37 00:02:15,300 --> 00:02:18,960 But when you're actually developing you actually use quite a bit and especially when you're releasing 38 00:02:18,960 --> 00:02:25,500 because you do have to you really have to add it in a bunch of data for pretty much a lot of things 39 00:02:25,500 --> 00:02:27,030 that happened within the program. 40 00:02:27,060 --> 00:02:29,880 So we have a variable name just like that. 41 00:02:29,880 --> 00:02:37,710 So what we can do is we can go to Web site in variable number k and we'll type this again. 42 00:02:37,710 --> 00:02:43,710 We call this variable name and you see him putting semi-colons at the end of this. 43 00:02:43,860 --> 00:02:44,940 And there you go. 44 00:02:44,940 --> 00:02:49,060 So the thing is is that these variables are the same thing. 45 00:02:49,320 --> 00:02:52,100 Right now they're just variables they're just boxes. 46 00:02:52,650 --> 00:02:55,190 Even will sign colors to these boxes. 47 00:02:55,200 --> 00:02:55,570 OK. 48 00:02:55,680 --> 00:02:59,600 So these are both a blank cardboard colored box. 49 00:02:59,620 --> 00:03:00,100 OK. 50 00:03:00,240 --> 00:03:06,800 But as soon as we do this and it's called initialising variables we type in equals zero. 51 00:03:07,920 --> 00:03:16,590 Now what we've done is we've changed this variable from being a a string variable or just a blank variable 52 00:03:16,590 --> 00:03:18,140 to an integer variable. 53 00:03:18,150 --> 00:03:25,230 Now again javascript's since it doesn't really distinguish between strings and ense like other languages 54 00:03:25,230 --> 00:03:25,640 do. 55 00:03:25,740 --> 00:03:27,400 We can actually mash these together. 56 00:03:27,450 --> 00:03:34,280 But for the most part to avoid errors you want to think of variable number as always going to be a number 57 00:03:34,280 --> 00:03:36,420 is never going to be a string. 58 00:03:36,420 --> 00:03:41,910 And in fact it's much better if you think this way because it will cause a lot of hard hardships down 59 00:03:41,910 --> 00:03:42,460 the road. 60 00:03:42,660 --> 00:03:44,610 Now let's go into variable name here. 61 00:03:44,730 --> 00:03:49,660 So what we need to do is you need to put in two quotes like this and we're going to type in your name. 62 00:03:49,680 --> 00:03:50,670 There we go. 63 00:03:51,150 --> 00:03:52,410 Pretty simple right. 64 00:03:52,750 --> 00:03:53,410 OK. 65 00:03:53,730 --> 00:03:56,020 Now let's just do something cool here. 66 00:03:56,070 --> 00:03:59,760 What we're going to do is we're going to go alert and watch this. 67 00:03:59,770 --> 00:04:04,000 We're going to type in variable number just like that. 68 00:04:04,210 --> 00:04:05,060 OK. 69 00:04:05,110 --> 00:04:06,000 There we go. 70 00:04:06,280 --> 00:04:11,000 Two warnings and if you change the text you see that it comes out to zero. 71 00:04:11,290 --> 00:04:19,540 And if we type in variable name just like this James the it comes out as my name. 72 00:04:19,870 --> 00:04:20,650 OK. 73 00:04:20,650 --> 00:04:32,250 So if we change this to whatever we want let's say too and we change it back to variable number. 74 00:04:32,260 --> 00:04:35,240 All right change the text and it comes out too. 75 00:04:35,360 --> 00:04:43,490 So what it is is that this alert and whenever you see this any kind of any kind of brackets it means 76 00:04:43,490 --> 00:04:44,810 you can put something in there. 77 00:04:44,840 --> 00:04:45,270 OK. 78 00:04:45,380 --> 00:04:47,530 So this alert here we typed in. 79 00:04:48,380 --> 00:04:54,470 You know we typed in a string here OK and it came out as pop but we can also put in any kind of variable 80 00:04:54,470 --> 00:04:59,930 we wanted to that and you'll also notice that there is a bracket here and that's for something really 81 00:04:59,990 --> 00:05:00,690 different. 82 00:05:00,710 --> 00:05:05,950 OK that's for something that's what you can put put variables into a function and they can do stuff. 83 00:05:06,080 --> 00:05:08,530 But we don't really need to worry about that quite yet. 84 00:05:08,530 --> 00:05:14,590 What I do want to show you is that you can actually go and put in variables wherever you want here. 85 00:05:14,600 --> 00:05:22,650 Now watch this if we want to change the text to a variable name just like this. 86 00:05:22,670 --> 00:05:28,370 We change the text and you can see that this is undefined here and the reason is is that I didn't put 87 00:05:28,370 --> 00:05:29,220 anything there. 88 00:05:29,240 --> 00:05:33,470 So let's just go ahead and put in a pop here. 89 00:05:33,590 --> 00:05:34,110 OK. 90 00:05:34,130 --> 00:05:39,360 And you'll also notice that when we do this here pop it does change to variable name. 91 00:05:39,370 --> 00:05:47,120 OK so I'll just go ahead and delete this here and you'll see here that if I just expand this out a bit 92 00:05:47,140 --> 00:05:49,130 it will be a little bit easier to look at. 93 00:05:49,130 --> 00:05:53,340 So what you'll see is you see the document or get an idea paragraph text. 94 00:05:53,440 --> 00:05:55,570 It's TMail equals two. 95 00:05:55,640 --> 00:06:02,970 The variable name or we can make it even two variable number k just like that. 96 00:06:03,020 --> 00:06:05,680 And if we change the text it changes too. 97 00:06:05,780 --> 00:06:06,240 OK. 98 00:06:06,320 --> 00:06:07,840 And so that's essentially what. 99 00:06:08,000 --> 00:06:09,980 That's essentially how you use variables. 100 00:06:09,980 --> 00:06:13,940 Again variables are really important because they can take in anything for example if you're making 101 00:06:13,940 --> 00:06:19,010 a calculator app you can take in the variable that was typed in and then added to something which I'll 102 00:06:19,010 --> 00:06:20,440 show you in the next tutorial. 103 00:06:20,460 --> 00:06:21,890 I'll see you guys next time.