From Comprehensions to JavaScript Array Methods (Summary)

Congratulations, you made it to the end of the course! The timing desk’s results cleaner now runs in JavaScript and produces the same report as the Python script. Bibs 23 and 58 have a missing chip read, the average finish time is 95.6 minutes, and Priya Nair, Mei Chen, and Tom Okafor win their age groups. At the start gun, the port prints an average of 0.0 minutes and no group lines, as Python does.

In this course, you learned how to:

  • Keep records with .filter() before transforming them with .map()
  • Pass .map() a function that fits the item, index, and array it receives
  • Build objects and Map objects from pairs, collect values in a Set, and flatten with .flatMap()
  • Destructure arrays by position and objects by name, with rest elements and defaults
  • Spread arrays, function arguments, and object properties
  • Check arrays with .some(), .every(), and .find(), and total with .reduce() and a start value
  • Find the shortest time with Math.min() and spread, or keep the best runner with .reduce()

Swap the Python Habits

Six Python habits needed a different line in JavaScript:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.