April 2015
Beginner
320 pages
7h 43m
English
One of the really cool things about arrays in JavaScript is that they can be sorted. Sorting is the process of looking at each item in an array and deciding whether it is greater than or less than another item in the same array. When all of the items in an array are sorted, the array is like a leaderboard—a ranked list of items. In this chapter, you’ll create a ranked list of players based on who has jumped most.
The Array.sort() method is used to sort items in an array. Let’s see it in action. Issue the following commands at the server console prompt:
js var animals = ['pig','wolf','cow','cat','sheep'];js console.log( animals );> pig,wolf,cat,cow,sheep ...
Read now
Unlock full access