Creating Variables
Variables act like a placeholder. Instead of typing values all the time again and again we can create variables and store values inside them. Then instead of typing again the value we can fetch the value by calling the variable's name. Each variable must have an identifying name, then we can assign a value to it by using the '=' operator. This takes whatever lies to the right part of the equation and assigns this value to the name of the variable to the left.
In order to retrieve information that has been stored to a variable you just call the variable with it's own name.
Variables are created with the use of var keyword, followed by the name of the variable and then the assignment operator with the corresponding value. For example:
var myAge = 30;
var myKidsAge = 10;
var jakeBecameFatherAt = myAge - myKidsAge;
console.log(ageIBecameFather);
Notice that a whole operation's result can be also stored into a variable, thus we don't need to call the whole operation again. Just the variable which holds the result of it.
There are some rules when it comes to JavaScript variable creation. The most important are:
1. JavaScript is case-sensitive. Be careful of uppercase or lowercase letters. The variables must be referenced exactly as they were named.
2. You are allowed to start with a letter or _ (underscore), but anything else is prohibited.
3. Your variable name cannot be a JavaScript reserved keyword. Find more about this in the link below.
http://www.informit.com/articles/article.aspx?p=131025&seqNum=3
Variables can be reassigned a value at any point without the var keyword. Var keyword is being used only for the initialization of the variable. Of course variables can hold values of different variables. (Only exception regarding the re-assignment part is the const keyword, but nothing to concern us for now).
// Things to do next:
Add a console.log after creating each variable and check the data type of each variable this time.
After that, create a new script that converts 5 different temperatures of your choice and returns the equivalent degrees in Kelvin. Given that a kelvin temperature is the celsius temperature with 273 degrees added.
Find if a number is an odd number or an even number with what you have learned today. You need to know some math to solve this (and a specific operator maybe).