Console + Variables


1. You can always log to the console

JavaScript
console.log(2 + 2);

4


2. Variables "hold" values

JavaScript
var myMessage = 'Hello there, world!";
console.log(myMessage);

Hello there, world!


3. If a variable holds a number you can do algebra

JavaScript
var cats = 3;
var dogs = 4;
var fish = 8;
var pets = cats + fish + dogs;
console.log(pets);

15

results matching ""

    No results matching ""