Chapter 3: Arrays, Logic, and Loops

In this chapter we’ll look at some of the data structures used in JavaScript to store lists of values. These are called arrays, sets, and maps. We’ll also look at logical statements that allow us to control the flow of a program, as well as loops that allow us to repeat blocks of code over and over again.

This chapter will cover the following topics:

  • Array literals

  • Adding and removing values from arrays

  • Array methods

  • Sets

  • Maps

  • if and else statements

  • switch statements

  • while loops

  • do … while loops

  • for loops

  • Iterating over a collection

  • Project ― we'll use arrays, loops and logic to ask multiple questions in our quiz

Arrays

An array is an ordered list of values. To create an array literal, simply ...

Get JavaScript: Novice to Ninja, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.