Create and Manipulate an Array6:49 with Dave McFarland
Practice simple arrays by creating an array literal, using indices to access array members and use methods like push, join, pop and shift to manipulate the array.
var. For example, to create a variable named temperature with a value of 98.9 you could do this:
var temperature = 98.9.
var works and you'll still see it around a lot. To get familiar with these keywords follow these rules:
const (which is short for constant) to store a value that won't change. For example, if you're setting the sales tax rate -- which won't change while your program is running you'd use
const. For example:
const taxRate = 7.5;
let to store a value that changes while the program runs. For example, if you're keeping track of a changing score, or the number of times a person clicks on a web page, use
let totalSales = 0;
var you can store any type of data in a variable defined with
const -- numbers, strings, arrays, objects, Boolean values, etc. If you are confused about whether to use
const the rule of thumb is if you're in doubt, use
To learn more, check out the workshop Defining Variables with let and const
Code for completed solution
You need to sign up for Treehouse in order to download course files.Sign up