Skip to content
Chapter 03 of 07 · 3 lessons · ~29 min

Functions, Arrays and Objects

Package your code into reusable functions and organize data with arrays and objects, the tools behind every real JavaScript feature.

YOUR PROGRESS0%
/ Lessons in this chapter
06
JavaScript Functions for Beginners How to write reusable functions with parameters and return values, including arrow functions. Coming soon
07
JavaScript Arrays and Array Methods How to create and change arrays, and how to use map, filter, find and reduce to work with lists. Coming soon
08
JavaScript Objects Explained How to store related information together in objects, read and update properties, and work with JSON. Coming soon

Chapter practice task

Task: Build a small price calculator for your services

  1. Store your services as an array of objects with a name and a price.
  2. Write a function that takes a list of chosen services and returns the total.
  3. Use filter to get only the chosen services and reduce (or a loop) to add the prices.
  4. Show the total on the page, formatted with a currency sign.
  5. Add a 10% discount when the total is over a set amount.

By the end of this chapter

  • You can write functions with parameters and return values, including arrow functions
  • You can use the most common array methods: push, map, filter, find, includes and reduce
  • You can create and update objects, and work with arrays of objects

Quick answers for this chapter

What’s the difference between a function and a method?

A method is just a function stored inside an object, like skills.push().

Arrays or objects?

Arrays for ordered lists of similar things; objects for one thing with named properties.

What’s JSON?

A text format that looks like JavaScript objects and arrays, used to send data between servers and browsers.