Back to Array Challenge
Code Studio · Level 7

Real JavaScript Objects

Build a character card. Objects store everything about one thing — its name, power, and score — so your hero travels through the code as one neat package.

15-20 min Ages 9-12 Real Code JavaScript

What is an object?

An object is a character card — everything about one thing, stored together. Instead of three loose variables, the robot's name, power, and score travel as one neat package.

robot 🤖 name: "Bolt" power: "star scanner" score: 10
  1. 1

    Build the card: let robot = { ... };

    Curly braces { } make an object. Inside, each line is a property: a label, a colon, and a value — name: "Bolt". Properties are like the rows on a trading card.

  2. 2

    Read with the dot: robot.name

    The dot reaches into the object and pulls out one property. robot.name is "Bolt", robot.score is 10. Object dot property — you'll type that thousands of times as a coder.

  3. 3

    Why coders use them

    A player, an enemy, a level — each is one object carrying all its own facts. Pass robot around and everything about Bolt goes along for the ride. Try adding a fourth property like speed: 99 and saying it!

Code Editor

Store named details.

Example code
let robot = {
  name: "Bolt",
  power: "star scanner",
  score: 10
};

say(robot.name);
say(robot.power);
say(robot.score);
Output

Program result

Robot ready to speak your strings

Type real JavaScript, then run it.