Just the glasses.
What? You thought you’d get to 2nd base after the first lesson? Let’s take it slow so you can concentrate.
Variables are common throughout every programming language. You should remember them from math class. Like x + y = 10, x and y are variables. Unless you were too busy hiding your boner during algebra class.
In any program you have to keep track of stuff. Like if we’re building a dating site, we’d need to keep track of my age, sexual preference, turn ons, favorite movies, and things like that. We put info like this into variables. A variable is just a container for a value. That value can vary, hence the name variable.
Now we need to assign a value to our variable like this, age equals 21. Which may or may not be my age. The shorter way to do it is just set the value when you declare the variable, like var age equals 21 all on the same line.
You can declare multiple variables on one line with commas, instead of separate lines. Like var = age, sex, location. You can also set their values at the same time. For all you youngins out there, this is how we used to do things on AOL. (beat) Don’t stalk me bro.
Back to script dot js for an example. We have var A equals 350 and var B equals 70. Then we set a new variable called total to A plus B. The value of total would be set to 420.
We use console dot log to output this value to the console. Just write console dot log and then the variable ‘total’ in parentheses. Now go back to the html page and hit refresh. You’ll see that the value has been output to the console. Once you get some mad brogramming skills from codebabes lessons you’ll use console dot log all the time to debug code.
In programming the PLUS sign is called an operator. You can also use MINUS, star for multiplying and forward slash for dividing.
A lot of times, a variable appears twice in a statement, like if we do var problems equals 9, and then, problems equals problems plus 90. Then the new problems variable would be 99.
But there’s a shortcut. Problems plus equals 90 would mean the same thing. You can do this with all the other operators too, minus, plus, star, you get the idea.
If we want to increment a variable’s value by one there’s an even better shortcut, which is plus plus. Plus plus is equivalent to plus equals 1. In programming you use this to increment a value by one. Like when you're looping over an array. That sentence might sound like you’re taking crazy pills, but we’ll talk about loops and arrays later in this course.
Next we’ll talk about conditional statements, and introduce the IF statement. You know, like IF you make it to the next lesson, THEN clothing Item minus minus. If you know what I’m saying.