Many Messages in One List

So far, you’ve asked your question of one message at a time, and the platform called your function once for each one. A report works with all the messages at once, so the platform keeps them together in a single value: a list.

By the end of this lesson, you’ll be able to read a list of messages, say how many it holds, and explain why an empty list still gives a useful answer.

Read a List of Messages

Here are messages 7, 8, and 9 from the earlier lessons, kept together under one name:

Language: JavaScript
> const messages = [
…   {
…     id: 7,
…     topic: "delivery",
…     status: "approved",
…     text: "My parcel arrived three days late.",
…   },
…   {
…     id: 8,
…     topic: "billing",
…     status: "approved",
…     text: "I was charged twice this month.",
…   },
…   {
…     id: 9,
…     topic: "delivery",
…     status: "pending",
…     text: "Where is my order?",
…   },
… ];
undefined
> messages
(3) [{…}, {…}, {…}]

A list like this is called an array. Here’s how to read it:

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.