1 00:00:00,760 --> 00:00:08,470 And Lou, let's learn some JavaScript, we're going to open up Google Chrome here and we're going to 2 00:00:08,470 --> 00:00:16,410 go to view developer and this time JavaScript console so you can do command option J as well. 3 00:00:16,720 --> 00:00:23,680 And it opens up this console, which is, if you remember elements, you've seen it before. 4 00:00:23,740 --> 00:00:27,400 That's your e-mail console is where we can write JavaScript. 5 00:00:28,420 --> 00:00:34,210 On the right, you'll see the outline of what we'll talk about in this JavaScript segment, we'll go 6 00:00:34,210 --> 00:00:37,330 one by one and some of them will come back to. 7 00:00:38,800 --> 00:00:42,580 But don't worry, by the end, you'll know everything in here. 8 00:00:43,790 --> 00:00:44,870 So let's talk JavaScript. 9 00:00:46,300 --> 00:00:49,270 JavaScript has seven types. 10 00:00:51,020 --> 00:00:54,800 You can think of types as values that JavaScript can have. 11 00:00:55,790 --> 00:00:56,960 Let's start with the first one. 12 00:00:57,820 --> 00:00:59,590 And that is No. 13 00:01:00,820 --> 00:01:01,930 So the number type. 14 00:01:03,690 --> 00:01:05,910 Well, in JavaScript, you can do something like this. 15 00:01:08,090 --> 00:01:12,660 Look at that, the console allows us to write JavaScript as much as we want. 16 00:01:12,710 --> 00:01:20,030 So by writing this and the console, giving us an answer means that, yep, this is valid JavaScript. 17 00:01:20,630 --> 00:01:21,740 OK, what else can we do? 18 00:01:21,770 --> 00:01:22,430 Well, we can do. 19 00:01:23,710 --> 00:01:29,930 Three times five, fifteen, 12, divided by four, three. 20 00:01:30,250 --> 00:01:31,750 That's awesome, what else can we do? 21 00:01:31,750 --> 00:01:33,040 12 minus four. 22 00:01:34,070 --> 00:01:34,700 Eight. 23 00:01:35,840 --> 00:01:37,840 Now, can we do this? 24 00:01:37,880 --> 00:01:47,000 Can we do three plus four close the bracket times two, so that's seven times to 14? 25 00:01:47,460 --> 00:01:52,160 Yeah, it works and we can even do this. 26 00:01:52,160 --> 00:01:55,010 And this is a special character that you might have not seen before. 27 00:01:55,340 --> 00:01:56,230 It's called module. 28 00:01:56,240 --> 00:01:57,230 And let's see what happens. 29 00:01:58,320 --> 00:01:59,230 Gives me zero. 30 00:01:59,460 --> 00:02:08,330 Hmmm, what if I do 12 modulo five, it gives me to what this symbol does and let's make this bigger 31 00:02:08,330 --> 00:02:09,800 so you can see clearly. 32 00:02:11,930 --> 00:02:16,910 And I'm going to clear this just so you can see it better, and I can do clear here with these brackets 33 00:02:16,910 --> 00:02:18,990 and I'll clean up everything for me. 34 00:02:19,790 --> 00:02:26,300 So one more time, what I did was 12 modulo five, and that gives me two. 35 00:02:26,300 --> 00:02:29,870 And what module does is it gives me their remainder. 36 00:02:29,870 --> 00:02:38,000 So 12 divided by five is what gives me a reminder of two, because five can only go to ten and then 37 00:02:38,000 --> 00:02:38,910 you have to remind her. 38 00:02:39,410 --> 00:02:41,930 So if I do, let's say 12. 39 00:02:43,190 --> 00:02:52,220 Modulo five or let's do nine, I get a remainder of three and you're thinking, oh God, you're just 40 00:02:52,400 --> 00:02:53,720 you're just teaching me math. 41 00:02:53,720 --> 00:02:56,630 But don't worry, this is only a small part of it. 42 00:02:56,760 --> 00:03:03,080 I just want to show you that the first JavaScript type is a number and we can do operations on them 43 00:03:03,080 --> 00:03:04,820 just like a calculator can. 44 00:03:06,390 --> 00:03:08,220 The second type in JavaScript is. 45 00:03:09,270 --> 00:03:09,990 A strength. 46 00:03:11,860 --> 00:03:19,690 So a string is just text and all you need to do to let JavaScript know that you're writing a piece of 47 00:03:19,690 --> 00:03:21,910 text is double quotes. 48 00:03:22,980 --> 00:03:24,330 So I can just say, Bob. 49 00:03:25,360 --> 00:03:29,950 I can say my name and you can also use single quotes. 50 00:03:35,200 --> 00:03:40,420 And that is a strength, but what else can we do with the strength? 51 00:03:40,840 --> 00:03:41,770 Let me clear this. 52 00:03:43,230 --> 00:03:47,160 Well, you can also do this, you can say hello. 53 00:03:49,730 --> 00:03:51,800 Plus, their what do you think will happen here? 54 00:03:53,370 --> 00:03:53,880 Let's see. 55 00:03:55,160 --> 00:03:58,610 Hello there, but it is one word. 56 00:03:59,720 --> 00:04:04,670 We need a space, so we would have to do hello space plus. 57 00:04:06,260 --> 00:04:06,620 They're. 58 00:04:09,030 --> 00:04:10,200 And there we have the space. 59 00:04:11,220 --> 00:04:16,440 OK, so we can add things, so add two sentences together. 60 00:04:17,870 --> 00:04:19,339 What if we do? 61 00:04:20,390 --> 00:04:21,860 What if we do something like this? 62 00:04:23,160 --> 00:04:27,690 This isn't very nice. 63 00:04:29,700 --> 00:04:33,820 I hit enter and OK, that works, that's good, but what if I use single quotes here? 64 00:04:34,770 --> 00:04:36,030 What if I go like this? 65 00:04:36,030 --> 00:04:39,850 And remember I said that I can use single quotes and JavaScript? 66 00:04:40,560 --> 00:04:42,720 Well, you see the syntax changes. 67 00:04:44,060 --> 00:04:49,700 And I get a little error, well, because I'm using a single quote and then inside the string, I'm 68 00:04:49,700 --> 00:04:50,980 trying to use a single quote. 69 00:04:52,150 --> 00:04:54,750 And that would happen as well if I use double quotes. 70 00:04:54,800 --> 00:04:56,920 If we go back to the example before. 71 00:04:58,510 --> 00:05:00,760 And I add another quote in here. 72 00:05:01,210 --> 00:05:05,530 Well, again, I get an error, so let me clear that. 73 00:05:07,300 --> 00:05:08,870 How can we avoid this problem? 74 00:05:08,890 --> 00:05:11,800 Well, with the string in JavaScript, we can do something like this. 75 00:05:13,510 --> 00:05:16,180 This is the new single quotes. 76 00:05:16,210 --> 00:05:20,140 This isn't and what's this? 77 00:05:23,700 --> 00:05:26,420 This isn't very nice. 78 00:05:27,560 --> 00:05:34,340 And this backslash has a special meaning, the backslash says, hey, whatever comes after this. 79 00:05:35,520 --> 00:05:38,410 It's a special meeting means just ignore it. 80 00:05:38,430 --> 00:05:41,640 Don't say that this is a piece of string. 81 00:05:41,670 --> 00:05:43,290 I just want the Batek. 82 00:05:43,950 --> 00:05:48,030 So if I run like this now, oops, I made the Syntex over here wrong. 83 00:05:48,060 --> 00:05:49,610 Obviously the quotes need to match. 84 00:05:49,620 --> 00:05:50,610 So let's try that again. 85 00:05:52,270 --> 00:05:52,810 There you go. 86 00:05:53,080 --> 00:05:54,130 This is a very nice. 87 00:05:55,630 --> 00:05:58,870 OK, I have another question, what happens here? 88 00:06:00,210 --> 00:06:01,050 Ten plus. 89 00:06:02,280 --> 00:06:08,150 String of thirty four, so that's number ten plus string of thirty four, let's see what happens. 90 00:06:09,770 --> 00:06:10,710 Hmm, weird. 91 00:06:11,630 --> 00:06:19,460 So JavaScript automatically looked at this and said he's adding a number and a string, he's probably 92 00:06:19,460 --> 00:06:22,160 trying to add strings together. 93 00:06:22,280 --> 00:06:27,480 So JavaScript converts the number 10 into a string then and does ten thirty four. 94 00:06:28,310 --> 00:06:29,370 That's kind of weird, right? 95 00:06:29,390 --> 00:06:31,160 It's one of the quirks of JavaScript. 96 00:06:31,170 --> 00:06:32,030 There's a few of them. 97 00:06:32,180 --> 00:06:33,440 You just have to get used to it. 98 00:06:34,070 --> 00:06:34,940 Let's try something else. 99 00:06:34,970 --> 00:06:38,540 What about if I do ten minus three? 100 00:06:40,070 --> 00:06:40,700 Press enter. 101 00:06:42,220 --> 00:06:50,740 I get seven what is going on here, and because with the string, you can really subtract the string. 102 00:06:50,740 --> 00:06:51,940 I mean, let's see if I go. 103 00:06:52,330 --> 00:06:53,050 Hello? 104 00:06:54,050 --> 00:06:54,770 Minus. 105 00:06:55,730 --> 00:06:56,300 By. 106 00:06:57,680 --> 00:07:04,070 I get this weird symbol which will get back to you, but that doesn't work, so now JavaScript says, 107 00:07:04,490 --> 00:07:05,750 I'm going to. 108 00:07:06,940 --> 00:07:11,350 Because he's subtracting I'm just going to assume that he means the number three, so he's trying to 109 00:07:11,800 --> 00:07:12,480 help you out. 110 00:07:13,480 --> 00:07:14,080 But. 111 00:07:15,350 --> 00:07:20,990 Sometimes it can have unexpected behavior, so ideally you never do things like this ideal, you keep 112 00:07:20,990 --> 00:07:26,180 numbers with numbers and strings with strings, and you keep the actions between the like types. 113 00:07:27,290 --> 00:07:30,980 So let's go back to this, what just happened when I say hello minus by. 114 00:07:32,110 --> 00:07:38,230 Well, and and stands for not a number, and it's technically in JavaScript, you can see the blue highlighting 115 00:07:38,230 --> 00:07:40,660 here, it's part of the number type. 116 00:07:41,260 --> 00:07:47,320 So numbers can, you know, can range from one to 10 to, you know, five hundred sixty seven. 117 00:07:47,320 --> 00:07:54,540 But there's also the A.N. when it's saying, hey, whatever you just wrote is not a number. 118 00:07:54,730 --> 00:07:55,910 So that's the case as well. 119 00:07:56,320 --> 00:08:01,540 I know it's really, really confusing, but don't worry is just the quirks of the language that we're 120 00:08:01,540 --> 00:08:01,960 learning. 121 00:08:02,800 --> 00:08:09,010 OK, I'm going to show you one other JavaScript type before we get to some fun things in the next video. 122 00:08:10,060 --> 00:08:12,820 So the next one is Bolian. 123 00:08:14,940 --> 00:08:19,740 And the bullying type is very simple, bullying just means true. 124 00:08:21,270 --> 00:08:27,840 Or false, that's it, and sometimes that could be presented as ones and zeros, and for those that 125 00:08:27,840 --> 00:08:33,600 know a lot about computers, you might know that computer is pretty much runs on ones and zeros. 126 00:08:33,600 --> 00:08:35,640 And that's that's where it comes from. 127 00:08:36,669 --> 00:08:43,750 But booleans are very, very useful because now we can do something like three is greater than two, 128 00:08:44,290 --> 00:08:53,110 and I'll say true, three is greater than two if I do, five is greater than 10 will say false. 129 00:08:53,140 --> 00:08:54,680 Five is not greater than 10. 130 00:08:55,630 --> 00:08:58,900 We can also do five is. 131 00:09:00,050 --> 00:09:07,070 Greater than or equal to five, so we'll say true, because I can do greater than equal to and I can 132 00:09:07,070 --> 00:09:09,740 also do five is. 133 00:09:10,890 --> 00:09:13,680 Smaller than or equal to five. 134 00:09:15,670 --> 00:09:21,280 Now, what if I want to say, does three equal three? 135 00:09:22,630 --> 00:09:24,200 Hmm, I get an error. 136 00:09:24,700 --> 00:09:25,450 Why is that? 137 00:09:26,380 --> 00:09:31,260 Well, because in JavaScript, if you want to say something is equal to something, you have to say 138 00:09:31,270 --> 00:09:34,960 three equals three equals sign three. 139 00:09:36,270 --> 00:09:42,770 And I got through and in the next video, I'll tell you why that's the case, it's very, very interesting. 140 00:09:42,780 --> 00:09:49,980 But for now, just remember, that's always a tricky point that a lot of beginners get confused about. 141 00:09:50,100 --> 00:09:53,160 Disremember if you're comparing two things, three, equal. 142 00:09:54,700 --> 00:10:01,180 The last one I want to show you is this three doesn't equal three. 143 00:10:03,780 --> 00:10:04,720 Isn't that confusing? 144 00:10:05,010 --> 00:10:06,990 So this is saying. 145 00:10:08,050 --> 00:10:13,930 Thus, three not equal, three false, because three equals three. 146 00:10:14,590 --> 00:10:21,230 I know it can get really, really confusing, but think of this as the opposite of the equal sign. 147 00:10:21,460 --> 00:10:28,330 So, for example, if I do four doesn't equal five, I'll get you, because you're right, four doesn't 148 00:10:28,330 --> 00:10:28,870 equal five. 149 00:10:31,030 --> 00:10:34,570 So what we just learned are JavaScript comparisons. 150 00:10:36,250 --> 00:10:38,810 And there the things right over here. 151 00:10:39,550 --> 00:10:40,090 That's it. 152 00:10:40,120 --> 00:10:41,320 You just have to remember this. 153 00:10:42,180 --> 00:10:44,780 Oh, well, that was that was fun, right? 154 00:10:45,550 --> 00:10:48,840 But we're just getting started after this video. 155 00:10:48,850 --> 00:10:50,580 I have left an exercise for you. 156 00:10:51,000 --> 00:10:56,740 Try to find the answers to the problems and then copy and paste them each of the questions, each of 157 00:10:56,740 --> 00:10:59,070 the line into the JavaScript console. 158 00:10:59,830 --> 00:11:04,960 So, for example, if I said, you know, evaluate three plus five, you'll copy this. 159 00:11:06,610 --> 00:11:12,130 Put it in the console and just press enter and I want you to be comfortable working with console and 160 00:11:12,610 --> 00:11:18,490 playing around with it, experimenting around and like I said, really try and work on the next problem 161 00:11:18,490 --> 00:11:18,890 sets. 162 00:11:18,910 --> 00:11:24,090 I haven't given you a lot because I don't want you to get overwhelmed. 163 00:11:24,670 --> 00:11:29,680 There's a lot more interesting things happening in JavaScript than this, and you can pick this up fairly 164 00:11:29,680 --> 00:11:30,100 easily. 165 00:11:30,520 --> 00:11:33,070 But I do encourage you to make sure you do the exercises. 166 00:11:33,650 --> 00:11:35,710 Now, can you get all of them? 167 00:11:36,810 --> 00:11:37,350 Good luck. 168 00:11:38,310 --> 00:11:39,390 I'll see you in the next video. 169 00:11:40,200 --> 00:11:40,530 Bye bye.