Teaching my 40 year old student with no experience programming | Data Types

Phil Choi teaches a 40-year-old beginner JavaScript fundamentals: cloning a repo, setting up VS Code, and working through data types. The lesson covers primitives like strings and numbers, variables with let and const, and the typeof operator with live coding examples.
Chapters
My favorite favorite number who wears. Is that. Is it a player?
No, it's my birthday. But Philip Rivers We're 17. War 17. Devonte Adams We're 17. All the best players wear 17.
Philip Rivers okay, he was good.
So the first thing after we cloned GitHub so let's just try it one more time. Friend minus RF JS course git is a distributed version control system that tracks versions of files. So basically if you want to share your code you use a program called git. It's very de facto everyone uses it and basically people can work on the same code base but branch out and then work on their own pace. So we'll go back to the GitHub repository, we'll type in the HTTPs link here. So you press on the green button and then HTTPs and copy this link. And what you want to do is say git clone on that URL.
So you can just copy it and.
Paste it and cloning and then you'll have the your the repository here. And from here you can just open your Visual Studio code. And first we'll go through the readme. So this is the JS course. It's the let fill JS course and during the first lesson we'll go through the intro and data types. So here how this is laid out is there's the readme you can add resources here and then there are going to be lessons so little modules. So we'll go through the intro and the data types and each of these modules have a readme and it'll be.
Good to reference there.
And then you have exercises for when you're done with all the modules. So let's go to intro. Tools needed README. So Intro to JavaScript what is JavaScript? JavaScript is a scripting language that is interpreted line by line and not compiled. So JavaScript is a scripting language and more lower level languages like C or C actually compiled that meaning JavaScript can run in the browser and it can change any moment. But older program like C or C, you'll have to send the whole file and then you get the machine code back and it is, it is used for web pages to add interactivity. So we'll get into that. That's in DOM manipulation. It is also used in non browser environments in the server with node js others. So where is JavaScript used? JavaScript is used in client side on the browser and manipulate and add interactivity to websites. JavaScript is used in the server and to connect to databases and serve data. JavaScript is also used in other non browser environments to execute commands in the server. So that meaning there are other use cases for JavaScript, not just a server or to serve HTTP requests, but you can actually use it as a scripting language or to run things like bots and all this kind of fun stuff. Who is JavaScript used by? JavaScript is used by programmers to make websites and build full stack applications. Why is JavaScript used? The reason why JavaScript is used because it is the only language that can be run in the browser and that's very powerful. It is used to add interactivity to websites. It is used to connect databases and serve data. How is JavaScript used? It is used by browser in the script tags that interactivity to websites. It is used with node JS to connect to databases and serve data.
Nice. We got through the intro, we got the tools needed. So now you have, you have, you have logging and you have variables. Right. So console log doesn't sound foreign and var, let and const do not sound foreign to you now. Right? Because we're going to need them for the next parts.
Okay.
All right, so data types and objects is our. We'll go back to the readme and we said in order, we'll go through intro and then data types. So we'll go to the folder data types and we'll go to the readme. There are primitives and data. So there's primitives meaning like the smallest pieces of data. You can call them atoms, kind of like strings. So these are like, do you know, like primary colors, like yellow, red and blue?
Yeah, yeah. Primary, secondary, tertiary.
Exactly. So when you're mixing like red and blue, you can kind of like make other pieces of like data. So that's how I kind of like.
To think about it.
So you have primitives like string numbers and booleans. Honestly, programming is just playing around with these three data types that we talked about from the intro. That's why I wanted to talk about an intro and then segue into here. So we have string, numbers, strings, numbers and booleans. And then for a later tutorial, we have other primitives called like big int. So that's just like referencing a big number. So you cannot mix like a regular number and a big number and null, undefined and symbol. And honestly, I don't even use big, int or symbol that much. So null and undefined are like the, the ones that we'll learn that will get into later. But today all we're going to think about is string, number and boolean. Is that okay?
Yeah, yeah, that works.
All right, so non primitives, like things that you put together, are probably like array arrays and objects, arrays being lists and objects being key value pairs. That might not make sense now, but it will in about five minutes. And we also have operators, so you need to be able to manipulate the data. So operators. I mean, it sounds weird, but I mean, it's just a plus minus, divide. So you take like two numbers and you kind of divide them, and those you just. Operators are what make expressions or. And we'll talk about that in a second. But basically they're just like comparisons. Like, does one equal one? Does one plus one equal two? Just. It's just a fancy word for, you know, plus and minus and increment and decrement. And we'll talk about that. We'll get into it in a second. But one that we'll use today is type of a type of logs, like a variable or a data, a piece of data and tells you if it's a string, a number or a boolean. So type of is something we're going to use today. We're going to use type of, we're going to use variables, and we're going to use all the data types we need. Expressions are a combination of values, variables and operators, which computes to a value. So just an expression would be like one plus one, that's an expression. So that's a combination of values, variables and operators, which computes to a value. So one plus one, that's using a variable operator and another variable and then that computes to a value. Right. It sounds like these computes and it's like programming terms, but it's just, it's very simple. Expressions can be used in many places in JavaScript, including as arguments to functions, which we'll get in today in Control, in Control structures, which we'll get in today and in assignments and in return statements. So an example of an expression is three plus four. That's an expression. And then we can even add , more equals seven and three plus four. Does three plus four equal seven? Yes. So this would be a true. It would compute into true three plus four. Right. This would equal seven. But now I'm. I made a comparison and I'm asking, does three plus four equal seven?
I see. Okay. Okay, I got it.
That's. That's all I was saying. Like, you could just keep on going on and on though, right? Three plus four, does it equal seven? Seven times seven? False. Right. And this is actually a whole expression. So there are three main data types we will work with string, number and boolean. So string being like a string, like hello world, it's just with quotes number 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and Boolean being a true or false. So Fun fact in JavaScript when it interprets 0 can also be false and 1 can be true. And that'll make more sense in our if else lesson that we're going to go through right after.
Okay.
Type of is a great tool to find out what data type you are working with. It comes in handy in if else statements that we will learn later. So type of is right. If you run like console log type of one, it'll give you. It'll say number. So if you see the console log type of hello, what do you expect to come out the string part?
Right? Just that it is a string.
Exactly. All right. So if I run node data types, it says string. Right. All right. And then maybe like I said, we'll.
Follow the practices that I said earlier.
Type of, what do you expect to come out here?
Number. Right. Type of 17. So should be a number. Favorite number who wears. Is that, Is it a player?
No, it's my birthday. But Philip Rivers were 17. War 17. Devonte Adams were 17.
Philip Rivers. Okay.
He was good. The sidearm girl.
Yes. No, no, I gotta give up for Philip Rivers just because he would be trash talking whether they were losing or winning. He was always so I gotta, you know, gotta give him the respect for that. Okay.
10 kids too.
Yeah.
Have you heard this?
No, I didn't. I did not know that.
But actually I don't like, you know, I'm a Raiders fan. So we all getting beat by the Chargers at that time.
Yeah. Lt's too. He's too good at that.
Exactly. Sean Marman. Oh my God. All right, all right. So, so here if we console log type of and then true. What do you expect to boolean?
Right?
Exactly. So I know this is like redundant and it's very easy, but it's just kind of hammering into your brain, I think.
Oh yeah, it's good, it's good.
So type of is very powerful. I'm just saying because like, let's just say you are in like a for loop or something or an if else and you say, hey, if this variable is a string I want to handle it this way and if it's a number, I want to handle it this way. And it'll be, it'll be handy later on. I think I have four exercises down here. I'm not going to help you whatsoever. So just make a variable using var that as a string. Don't even think about it. Just put A.
Okay.
Yeah, like a B, J. Cool.
Make a variable using constants a number Const. B equals 42. Oh, 45 is good.
42.
The answer to life.
No.
Make a variable let. That's a Boolean. Oh, Jesus. Let's see. But if it's a boolean, it's got to be one or the other, right?
Exactly. I don't know.
I don't know about that. Reassign above variable into the opposite.
You see how there's a red line now? We cannot redeclare block scope variable C. So when you're reassigning, like the reason why it's lead, you don't need to initiate it anymore. So you can just get rid of the lead.
Okay.
That's the meaning. That's the. The power of lead. Like, you initiate it once and you don't need to use an initializer again. So you can honestly think, like var concert are like initializers. I think that's what, like the. It'll. It'll like throw an error like that. So you already initialize C and now you're just reassigning C. Okay. Does that make sense?
Yeah, that makes sense. And I can do that with var also. But if I do const again, then it's going to throw an error because.
Exactly. Okay, so if you do like B equals 42, it's going to throw an error. We can try it. So if we run node data types, we get a big assignment to constant variable.
It's not.
Okay, line 27, right?
There it is. Yeah.
Okay, but we don't have the error on 31, so can you. On line 32, can you consolate log the four very the three variables we made A, B, and C all in one line.
Console log.
All right, and why don't you click save or command? S.
It work?
Yes. And then why don't you run it in the terminal here? So then if we put console log, type of A, type of B, type of C, what do you expect this to. What do you expect line 34 to output?
String. So we'll say string. String number boolean.
Exactly. So why don't you try to run that and see if you're correct. You can just hit right arrow so you don't have to type it out all the time.
There it is.
All right.
You got it. Amazing.
The right arrow part. That's what I'm talking about. I saw the predictive text okay. Okay.
Right arrow or tab. Any questions so far? No.
No. I think it's. I think that's. I think it's good.
Okay, so now we have. Now we have string, number, and boolean. We know how to play around with those. And now we can use type of. And we can hold them in variables and log them. So now you have some tools in your belt, right? You have console log, you have logging, you have variables, and you have data like strings and booleans and numbers you type up. So we have those. All right, so we're going to go into operators. So those are. That's like the one plus one. Just creating expressions with what you learned just now.
Okay.
More from Phil

day in the life of a software engineer | 5 hour productivity | building my dev agency 🔥

day in the life of a software engineer | 3 hour productivity | coding my 6-figure community startup

day in the life of a software engineer | 5 hour productivity | coding our sns startup app LFG

day in the life of a software engineer | 5 hour productivity | creating apps that makes big money






