Loading video player…

Write Reusable Reporting Functions (Overview)

In this video, you met the report you’ll build in this course: it answers a question about customer feedback and lists the message IDs behind every count, so you can check each number yourself. Here’s what to keep from it.

Key Points

  • Someone on a support team reads customer feedback and asks: which of this week’s messages are about delivery? In this course, you’ll build the report that answers that question.
  • Three of this week’s six messages are about delivery. The report also lists their IDs, so you can open each message and check the count.
  • On next week’s messages, the same report finds three of five about the app.
  • Right now, a second report means copying your counting loop and changing the topic. Fix one copy, forget the other, and the two reports stop agreeing.
  • In this course, you’ll write each rule once, as a small function with clear inputs and results. Then you’ll combine those functions into a report that works for any topic and any set of messages.
  • In the project, you’ll plan this report, build it on two sets of messages, add a function of your own, and explain your report to the mentor, message by message.
  • AI can write useful code. Learning programming helps you understand how that code works. It also helps you describe what you want and adapt the result. That’s what lets you explain every number in your report.
  • You should already be able to count matching records with a loop and a condition. You’ll write your code in RealJS exercises, in your browser.

The Report You’ll Build

This week’s messages:

ID Topic Text
M-301 delivery Box came late
M-302 billing Charged twice
M-303 delivery Wrong address
M-304 app Login fails
M-305 billing No refund yet
M-306 delivery Left in rain

Asked about delivery, the report answers with three of this week’s six messages and their IDs:

Language: Program Output
delivery 3 of 6
M-301
M-303
M-306

Next week’s messages:

ID Topic Text
M-701 app Crashes on start
M-702 returns No label
M-703 app Reset fails
M-704 delivery Parcel lost
M-705 app Search is empty

Asked about the app, the same report answers with three of five:

Language: Program Output
app 3 of 5
M-701
M-703
M-705

First up is the lesson Name a Reporting Rule and Call It.

You can keep a local reference copy of this course’s source code. Try the exercises before opening the completed solutions:

Become a Member to join the conversation.