Command Palette

Search for a command to run...

Hectal
Phase 1: JSX: Writing UI in JavaScript
React · Exercise 2 of 6 PreviousNext
Beginner

A profile card from data

The user object holds the data. Fill the card with curly braces so it shows the data, not fixed text:

An <h2 id="name"> with the full name (first and last with a space between). An <img> whose src is user.photo and whose alt is Photo of followed by the full name. A <p id="age"> saying Age: and the age, calculated as THIS_YEAR - user.born. A <p id="status"> saying Online with the classes status online when user.online is true, otherwise Offline with the classes status offline.

Then change the data (for example online: false) and check that the card follows.

What Check tests

  1. The heading shows Asha Rao
  2. The image uses user.photo and the alt text Photo of Asha Rao
  3. The age is calculated: Age: 12
  4. The status says Online with the classes status online
  5. The values come from user, not typed in

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.