Java Script Lesson 1 Numbers and Strings + Console Log

This will be my first time “teaching” anyone Java Script but I will do my best in this lesson and the next couple to explain the very basics of the language and how it works.

The first thing that you need to understand is that every coding language has a syntax. This is the way that the code is written and what specific signs or symbols may need to be typed in to make it work/run. The most basic and arguably most important syntax in Java Script is the semicolon “;”. This handy character allows us to essentially finish our lines of code in Java Script letting the computer know that we are done typing into this specific line of code. Forgetting to type this symbol at the end of lines of code is the most basic error that is made by beginners but it is not a big deal as websites such as code.org let you know when this happens

Image courtesy code.org
Image courtesy code.org

This is what it looks like in code.org when there is no semicolon at the end of a line of code. When there is it should look like this.

Image courtesy code.org

You should be able to see the number and that indicates the line of code your on and that you have no errors. The yellow caution signs indicate a minor error in your code such as a slightly incorrect syntax or a missing semicolon however if there is a large red square that indicates a big error in your code that will cause it to not run.

Image courtesy code.org

Can you spot the error? The problem is there is no parenthesis around the quoted text hello world. This causes the computer to think you are typing out one solid command that says in console log hello world as opposed to in console log display text hello world.

The final part of this lesson will go over the first place we will apply our coding knowledge, The console log. The console log is essentially a separate mini code player that can be used primarily to display text. We can use the variable operator console.log () to display numbers and console.log (“”) to display text or strings. Strings are just a fancy way of saying text that is used by computers. Strings need the quotation marks to identify themselves because they work differently than numbers.

These are the exact same code using the division operator however one is a number being divided the other is a string. The string cannot be divided so this becomes the output for the code

It becomes 10 which is the correct output for out first line of code but it becomes NaN or not a number for our second line of code. This is because strings can only be used with the addition operator. But I will get into that next lesson.

Thank you all for reading I hope you enjoyed and as always feel free to swing by my YouTube channel where I just uploaded a new video!

Link: https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg

Where I’ve been

Its been quite a while since I’ve uploaded anything on my website and the main reason for that was truly that I didn’t think about it and prioritize correctly for the last almost year. I’m going to make sure to not make that mistake again and not make anymore excuses so I’m going to be uploading between 2-4 blog posts a week as well as consistent cooking content on my YouTube channel, which I will link below. This blog will still be coding centered but I have been talking about and thinking for a while to switch from block code like the format used in Scratch to Java Script. Which is exactly what I will be doing, however if you ever have any questions about anything I’m doing or have done whether it’s Scratch or Java Script feel free to leave a comment and I will do my best to get back to you as soon as possible. The main reason I have decided to make this switch is because I just entered my Freshman year of high school and I’m taking an AP Computer Science principles class. We focus on the use of Java Script to develop apps that perform specific functions. The main website I use is code.org which is a great free platform for any beginner

I would highly recommend checking them out but another place that you can use as a place to code is Khan academy. I’ve found that their lessons are a little bit less challenging and have more instruction where as code.org has more individual paced lessons which allow for more creative freedom. Unfortunately that’s all I have to talk about for today’s post but tomorrow I will be starting lesson one in my own intro to Java Script course feel free to stop by and read all about the wonderful world of Java.

Thank you for reading this blog post it means a lot feel free to stop by my YouTube channel for cool cooking videos cooking is one of my favorite hobbies and I like to think I’m pretty good. I’ll be uploading another recipe on their tomorrow. Link: https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg