Exercises

The following exercises provide you with the opportunity to practice with optimizing your code. The solutions to these exercises are found in the section Chapter 20.

  1. You’re working on software that analyzes sports players. Following are two arrays of players of different sports:

     const basketballPlayers = [
      { firstName: 'Jill', lastName: 'Huang', team: 'Gators' },
      { firstName: 'Janko', lastName: 'Barton', team: 'Sharks' },
      { firstName: 'Wanda', lastName: 'Vakulskas', team: 'Sharks' },
      { firstName: 'Jill', lastName: 'Moloney', team: 'Gators' },
      { firstName: 'Luuk', lastName: 'Watkins', team: 'Gators' },
     ];
     
     const footballPlayers = [
      { firstName: 'Hanzla', lastName: 'Radosti', team: '32ers' },
      { firstName: 'Tina', ...

Get A Common-Sense Guide to Data Structures and Algorithms in JavaScript, Volume 1 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.