And Lou, let's learn some JavaScript, we're going to open up Google Chrome here and we're going to
go to view developer and this time JavaScript console so you can do command option J as well.
And it opens up this console, which is, if you remember elements, you've seen it before.
That's your e-mail console is where we can write JavaScript.
On the right, you'll see the outline of what we'll talk about in this JavaScript segment, we'll go
one by one and some of them will come back to.
But don't worry, by the end, you'll know everything in here.
So let's talk JavaScript.
JavaScript has seven types.
You can think of types as values that JavaScript can have.
Let's start with the first one.
And that is No.
So the number type.
Well, in JavaScript, you can do something like this.
Look at that, the console allows us to write JavaScript as much as we want.
So by writing this and the console, giving us an answer means that, yep, this is valid JavaScript.
OK, what else can we do?
Well, we can do.
Three times five, fifteen, 12, divided by four, three.
That's awesome, what else can we do?
12 minus four.
Eight.
Now, can we do this?
Can we do three plus four close the bracket times two, so that's seven times to 14?
Yeah, it works and we can even do this.
And this is a special character that you might have not seen before.
It's called module.
And let's see what happens.
Gives me zero.
Hmmm, what if I do 12 modulo five, it gives me to what this symbol does and let's make this bigger
so you can see clearly.
And I'm going to clear this just so you can see it better, and I can do clear here with these brackets
and I'll clean up everything for me.
So one more time, what I did was 12 modulo five, and that gives me two.
And what module does is it gives me their remainder.
So 12 divided by five is what gives me a reminder of two, because five can only go to ten and then
you have to remind her.
So if I do, let's say 12.
Modulo five or let's do nine, I get a remainder of three and you're thinking, oh God, you're just
you're just teaching me math.
But don't worry, this is only a small part of it.
I just want to show you that the first JavaScript type is a number and we can do operations on them
just like a calculator can.
The second type in JavaScript is.
A strength.
So a string is just text and all you need to do to let JavaScript know that you're writing a piece of
text is double quotes.
So I can just say, Bob.
I can say my name and you can also use single quotes.
And that is a strength, but what else can we do with the strength?
Let me clear this.
Well, you can also do this, you can say hello.
Plus, their what do you think will happen here?
Let's see.
Hello there, but it is one word.
We need a space, so we would have to do hello space plus.
They're.
And there we have the space.
OK, so we can add things, so add two sentences together.
What if we do?
What if we do something like this?
This isn't very nice.
I hit enter and OK, that works, that's good, but what if I use single quotes here?
What if I go like this?
And remember I said that I can use single quotes and JavaScript?
Well, you see the syntax changes.
And I get a little error, well, because I'm using a single quote and then inside the string, I'm
trying to use a single quote.
And that would happen as well if I use double quotes.
If we go back to the example before.
And I add another quote in here.
Well, again, I get an error, so let me clear that.
How can we avoid this problem?
Well, with the string in JavaScript, we can do something like this.
This is the new single quotes.
This isn't and what's this?
This isn't very nice.
And this backslash has a special meaning, the backslash says, hey, whatever comes after this.
It's a special meeting means just ignore it.
Don't say that this is a piece of string.
I just want the Batek.
So if I run like this now, oops, I made the Syntex over here wrong.
Obviously the quotes need to match.
So let's try that again.
There you go.
This is a very nice.
OK, I have another question, what happens here?
Ten plus.
String of thirty four, so that's number ten plus string of thirty four, let's see what happens.
Hmm, weird.
So JavaScript automatically looked at this and said he's adding a number and a string, he's probably
trying to add strings together.
So JavaScript converts the number 10 into a string then and does ten thirty four.
That's kind of weird, right?
It's one of the quirks of JavaScript.
There's a few of them.
You just have to get used to it.
Let's try something else.
What about if I do ten minus three?
Press enter.
I get seven what is going on here, and because with the string, you can really subtract the string.
I mean, let's see if I go.
Hello?
Minus.
By.
I get this weird symbol which will get back to you, but that doesn't work, so now JavaScript says,
I'm going to.
Because he's subtracting I'm just going to assume that he means the number three, so he's trying to
help you out.
But.
Sometimes it can have unexpected behavior, so ideally you never do things like this ideal, you keep
numbers with numbers and strings with strings, and you keep the actions between the like types.
So let's go back to this, what just happened when I say hello minus by.
Well, and and stands for not a number, and it's technically in JavaScript, you can see the blue highlighting
here, it's part of the number type.
So numbers can, you know, can range from one to 10 to, you know, five hundred sixty seven.
But there's also the A.N. when it's saying, hey, whatever you just wrote is not a number.
So that's the case as well.
I know it's really, really confusing, but don't worry is just the quirks of the language that we're
learning.
OK, I'm going to show you one other JavaScript type before we get to some fun things in the next video.
So the next one is Bolian.
And the bullying type is very simple, bullying just means true.
Or false, that's it, and sometimes that could be presented as ones and zeros, and for those that
know a lot about computers, you might know that computer is pretty much runs on ones and zeros.
And that's that's where it comes from.
But booleans are very, very useful because now we can do something like three is greater than two,
and I'll say true, three is greater than two if I do, five is greater than 10 will say false.
Five is not greater than 10.
We can also do five is.
Greater than or equal to five, so we'll say true, because I can do greater than equal to and I can
also do five is.
Smaller than or equal to five.
Now, what if I want to say, does three equal three?
Hmm, I get an error.
Why is that?
Well, because in JavaScript, if you want to say something is equal to something, you have to say
three equals three equals sign three.
And I got through and in the next video, I'll tell you why that's the case, it's very, very interesting.
But for now, just remember, that's always a tricky point that a lot of beginners get confused about.
Disremember if you're comparing two things, three, equal.
The last one I want to show you is this three doesn't equal three.
Isn't that confusing?
So this is saying.
Thus, three not equal, three false, because three equals three.
I know it can get really, really confusing, but think of this as the opposite of the equal sign.
So, for example, if I do four doesn't equal five, I'll get you, because you're right, four doesn't
equal five.
So what we just learned are JavaScript comparisons.
And there the things right over here.
That's it.
You just have to remember this.
Oh, well, that was that was fun, right?
But we're just getting started after this video.
I have left an exercise for you.
Try to find the answers to the problems and then copy and paste them each of the questions, each of
the line into the JavaScript console.
So, for example, if I said, you know, evaluate three plus five, you'll copy this.
Put it in the console and just press enter and I want you to be comfortable working with console and
playing around with it, experimenting around and like I said, really try and work on the next problem
sets.
I haven't given you a lot because I don't want you to get overwhelmed.
There's a lot more interesting things happening in JavaScript than this, and you can pick this up fairly
easily.
But I do encourage you to make sure you do the exercises.
Now, can you get all of them?
Good luck.
I'll see you in the next video.
Bye bye.