StaffCoder
TypeScript
Vanilla TypeScriptTypeScript 7.0
6 modules · 24 challengesSign up
Module 1 · Dom Selection & Manipulation

Dashboard Tile Grid

easy50%1 of 2 solved

Problem statement

A reusable function that fills a metrics dashboard from a list of metrics using Vanilla TypeScript and standard DOM APIs. The page provides an empty container — the function builds every tile and puts them in place, rather than assembling the dashboard out of HTML text.

Demo

The page, styles, dashboard container, and metric data are already scaffolded and wired. Only the renderDashboardTiles function is missing — implement it in src/dashboardGrid.ts so every test passes. Do not edit any other file.

What to implement

  • Take a container and a list of metrics, and fill that container with them.
  • Produce one tile per metric, keeping the order the metrics arrived in.
  • Give every tile its own element for the label, its own for the value, and its own for the unit.
  • Show each value word for word, exactly as the metric supplies it.
  • Attach each metric's key to its tile, so a tile can be traced back to the metric it came from.
  • Mark every tile with how the metric is trending, so a rising, falling, and unchanged metric each read differently at a glance. A tile shows one trend and never more.
  • Single out the tiles that have not reached their target, and leave the ones that have met or passed it alone.
  • Show a stand-in message instead of the dashboard when there are no metrics to show, with no tiles alongside it.
  • Fill the container you were given, rather than building a new one to take its place.
  • Everything the dashboard shows must come from the metrics you were given. Nothing should be fixed in advance.

More in Dom Selection & Manipulation

See the module
Product Card RendererBuild an entire product card in TypeScript from a product object (name, price, rating, inStock, imageAlt) — create every element, set text content, the image alt, a data-* attribute for the id, and a stock class derived from inStock. Format the price to two decimals. The renderer returns the node without ever touching the document, and two calls with the same product produce two independent nodes.25%2 of 8 solvedeasyNotice Banner StatesImplement a banner controller that switches between four states (info, success, warning, error) using classList only, sets the message text via textContent, and updates role and aria-live to match the state. Hiding the banner clears the message and removes every state class so states never overlap.50%1 of 2 solvedeasyTable Row Builder Build table rows from an array of records using createElement and a DocumentFragment, appending to <tbody> in a single operation. Money cells receive a numeric class; each row carries a data-* id; cell text is set via textContent so a value containing angle brackets renders as text, not markup; and an empty array leaves the <tbody> untouched.100%1 of 1 solvedeasy

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.