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: