Lesson 1

Explanation

Intro

Console.log

In this lesson, you'll be learning various introductory topics that get you up and running quickly in coding. The first bit you'll learn is the console.log();. Without a web page to hold your javaScript (JS), you'll need something to display the code you type. That's what the console is for. When you use console.log();, you are telling the console to "log" or print what ever you put inside the parentheses.

When you're using Codecademy, they provide you a console window. You code in the center, and the console displays the output. When you're completing checkpoints for me, you'll use my console I created. It has the same basic principal, but it can be a little finicky.

A note about the parentheses. If you put a number (and nothing else) in the parentheses you don't need any quotes. If you put a word or a combination of words and numbers, you have to use quotes. Speaking of quotes, you may use double or single, either one, but not both at the same time. Generally speaking though, in JS we use single quotes; in html and CSS, we use double quotes.

Examples

  • console.log(46);
  • console.log('Wow');
  • console.log("Wow");
  • console.log('Wow + 46');
  • console.log("Wow + 46");

Comments

Using comments in writing JS is just as important (if not more so) as in HTML and CSS. But because JS is very linear (or line based) you must choose between a single line comment and a multi line comment. Don't hesitate to use comments. I realize that at the moment putting comments into your work seems more like an assignment rather than something helpful. But trust me, if you neglect putting comments into your work, you'll realize the need, when you go back through your lessons looking for that one bit of code that did just that one certain thing, that you can't remember now.

Other Information

You'll also learn the different data types, how math symbols work (operators), plus some built-in commands that will make your life much easier.

Variables

In part 2 of lesson 1 you'll learn all about variables. This is pretty straight-forward. You'll learn to declare variables and set the value. Here are the basics:

  1. Decare a variable:
    var
  2. Name the variable:
    var age
  3. Set the value:
    var age = (46); In this case I set it to a number.

Activities

  1. Create an account with Codecademy. Be certain to use your school Google account. Codecademy will attempt to convince you to pay to unlock more content, but that is not needed for this course.
  2. Complete the Introduction to JavaScript. There are 10 exercises to in this section. This will take you two class periods at most.
  3. Complete the Variables lessons in Codecademy. Again, there are 10 lessons here.
  4. Complete the checkpoint for this lesson. Found in Google Classroom.

Resources