Learn to Code – Lesson 01 – Variables and Basic Data Types

hey there so you want to learn how to code but you don't know where to start that's what we're going to deal with today and we're going to use JavaScript as a model because JavaScript is something anyone with a text editor and a web browser can write there are plenty of other languages but Java scripts are good one to start with because the syntax is easy to understand and you can transfer over what you learn in JavaScript to other languages like it such as ActionScript which is what is used to write code for Adobe Flash and it's also a syntax that is very similar to other languages PHP for example is not that much different and just a few things change in terms of how the code is written and we'll get into some of those differences later but let's start by writing a basic script and seeing what it does for every programmer the place that you generally will start is a HelloWorld script and that's just to say I have written a very basic program and it is able of communicating a very simple message to the rest of the world so we're going to start out by writing a very simple HTML document this is as simple as it gets and I'm just going to put a head tag there that's where we're going to keep our script we'll call the title of this page my script and then we're going to put a script tag in here type is text slash JavaScript that's what we're going to be writing in close that up and here is where our scripts going to start now javascript has an interesting way of communicating and that is to pop up dialogues which was probably useful in the past and still useful today but it's kind of annoying to get those pop-up dialogues but this is how you can test to see if your code is working and your information is getting through so you make a function a function is represented when being called like this and that's on the alert function which will bring up a dialog so if I just put the text in here hello world in quotation marks and save this I go into my web browser the web browser I'm temporarily using to test this stuff I reload the page and it says hello world now the reason I'm able to do text here is because it is in quotation marks and that means that I am passing the alert function of variable and that variable is is the text hello world and that type of a variable is a string now string is represented in quotation marks like that I could also pass it a number which I do not have to pass in quotation marks so I could just pass it the number three like so and then I get an alert that says three another simple data type is the boolean data type and that is passed simply as the words true or false so I would have put true in here I don't have to put in quotation marks it'll just show up as true and that's really good for testing things and we'll get into what these data types do a little bit more later but those are the primary data types you'll be using to read simple applications now to take this a little bit further you're not just going to want to pass data as you need it in quotation marks or as numbers or whatever you're going to want to store them in containers and those containers are variables to declare a variable you don't have to do much you can just say my variable equals hello world and then you end that line with a semicolon and that's how you end all of your lines and code to say okay I'm all done otherwise JavaScript is going to go to the next line and say oh there's more to this and you may not want that and it will cause errors in your code and JavaScript is not that great without some extra tools it's not going to just tell you what's wrong with your code it just won't work that's where alert comes in to start testing things you're probably not use it in actual production code but to find out if something's working if you're using just JavaScript to test alert is how you're going to do that so instead of putting hello world in quotation marks in alert I'm going to put alert my variable and then alert is going to say Oh what what it what are the contents of my variable and see how this isn't in quotation marks it's because I'm calling something else that was declared in the code so it's going to say what's inside my variable and then we've already set that here so it's going to be oh my variable contains hello world so if we reload the page now we get a broadcast of hello world now here's where things start to differ in other languages some are strictly typed and some are loosely typed javascript is a loosely typed language because I was just able to say my variable equals hello world but that is not very specific I'm not saying it's a variable which I can declare by saying var my variable and I'm also not saying what kind of variable it is now JavaScript realize it realizes that this is a string because I have it in quotation marks but to strictly type something you put colon string now you don't do this in JavaScript but if you're in ActionScript this is how you would declare a string variable but we can just do it like this now you will hear arguments on both sides whether strictly typed or loosely typed is better I personally prefer strictly typed because that I know exactly what I'm dealing with and there's less room for error because you specify everything but then it can also cause some problems and make your code a little bit more difficult to deal with so there are arguments on both side but basically that is how you make a variable in our next video we're going to take a look at how to add things and concatenate different strings so you can start having some fun with variables

30 thoughts on “Learn to Code – Lesson 01 – Variables and Basic Data Types

  1. Awesome video! I make tutorial videos as well over programming languages and other tech related topics if anyone thinks they would benefit! Would super appreciate it you would subscribe! 😀

  2. OH MY GOD

    Please someone tell me where the sound effect in the intro is from its driving me insane

  3. I have to agree with @TheNobletan — I'm a graphic designer and I even have a little bit of knowledge of code, but this is like 20 lessons ahead. You need to start at the beginning, and explain what each element is, and why it is what it is. It's like, why are you using parenthesis, and how do you structure the code etc. I do appreciate you doing this, though… although it feels like it's for someone who's already a beginner at this stuff.

  4. He is using text mate which only works with macOs operating systems up to 10.8. I am using High Sierra. Are there any alternatives that will work?

  5. Where are you typing this?? I can get what you are saying but I have no idea where you are writing this code. Could you explain..?

  6. hm interesting. Thought about taking a computer science course but I think I should watch some more videos instead of jumping into that. Great video btw

  7. This is not for beginners. This is a vidoe u make to show your knowledge in terms of web development so u get contacted by those who want to work with u.

  8. Ok what does <> mean? Does everything have to be in <>?
    Is there a page that defines all the symbols and has all the others html, head, script type, head, body, html, So is there a order to it? I would like a vocabulary sheet.

Leave a Reply

Your email address will not be published. Required fields are marked *