Command Palette

Search for a command to run...

Hectal
Phase 6: Objects
JavaScript · Exercise 1 of 5Next
Beginner

A pet object with a method

Fill in the pet object with three properties: name (a string), type (a string, like "cat") and age (a number).

Add a method describe() that returns text like Bruno is a 3-year-old dog, built from the object's own properties with this.

Show the result of pet.describe() in the #out paragraph.

What Check tests

  1. pet has a string name, a string type and a number age
  2. describe() returns the sentence in the right format
  3. describe() uses the current values (through this)
  4. The page shows the description
  5. No errors

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.