O'Reilly logo

JavaScript: Novice to Ninja by Darren Darren Jones Jones

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3Arrays, Logic, and Loops

In the last chapter we were introduced to JavaScript’s primitive values, and also did a bit of programming. In this chapter we’re going to look at arrays, a useful data structure for storing lists of values. 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.

We will cover the following topics:

  • array literals

  • adding and removing values from arrays

  • array methods

  • if and else statements

  • switch statements

  • while loops

  • do … while loops

  • for loops

  • iterating over an array

  • our project―use arrays, loops, and logic to ask multiple questions in our quiz

Arrays

An array is an ordered list of values. To ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required