reading-notes

Operators & Loops

Expresssion

Expressions can be used in a variety of contexts in JavaScript such as:

-variable assignments

-conditional statements

-loops

-function calls

Array

A data structure that stores a collection of values such as numbers, strings, objects, or other arrays.

To create an array enclose a list of values inside square brackets “[]”. Separate array items by commas.

Ex. var numbers = [1, 2, 3, 4, 5];

Loops

A loop allows you to execute a block of code repeatedly as long as a certain condition is met.

Types:

“for” most common

ex. Make an array: var numbers = [1, 2, 3, 4, 5];

-Use a “for” loop to iterarte the array numbers:

for (var i = 0; i < numbers.length; i++) { console.log(numbers[i]); }