JS
…

Module 9 of 10

objects

Create objects, read properties, and add methods.

JavaScript Basics · 0/12 completed · scroll down for every challenge

Challenge 1 of 12

Create an object

Instructions

Create `user` with `name: "Riya"` and `age: 24`.

Editor

IntelliSense on

// Write your code below

Challenge 2 of 12 · Bracket access

Challenge 2 of 12

Bracket access

Instructions

Read `city` from `profile` using bracket notation into `place`.

Editor

IntelliSense on

const profile = { city: "Mumbai", country: "IN" };
// Write your code below

Challenge 3 of 12 · Update a property

Challenge 3 of 12

Update a property

Instructions

Set `player.score` to 120. `player` already exists.

Editor

IntelliSense on

const player = { name: "Ava", score: 0 };
// Write your code below

Challenge 4 of 12 · Object method

Challenge 4 of 12

Object method

Instructions

Add method `bark()` to `dog` that returns `"woof"`.

Editor

IntelliSense on

const dog = { name: "Max" };
// Write your code below

Challenge 5 of 12 · Destructuring

Challenge 5 of 12

Destructuring

Instructions

Destructure `title` and `year` from `book`.

Editor

IntelliSense on

const book = { title: "Eloquent JS", year: 2018 };
// Write your code below

Challenge 6 of 12 · Add a property

Challenge 6 of 12

Add a property

Instructions

Add `active: true` to `account`.

Editor

IntelliSense on

const account = { id: 1 };
// Write your code below

Challenge 7 of 12 · Nested property

Challenge 7 of 12

Nested property

Instructions

Store `user.address.city` in `city`.

Editor

IntelliSense on

const user = { address: { city: "Pune", pin: 411001 } };
// Write your code below

Challenge 8 of 12 · Object keys

Challenge 8 of 12

Object keys

Instructions

Store `Object.keys(user)` in `keys`.

Editor

IntelliSense on

const user = { name: "Sam", age: 20 };
// Write your code below

Challenge 9 of 12 · Has own property

Challenge 9 of 12

Has own property

Instructions

Set `hasAge` to true if `"age"` is a key on `user` (`"age" in user`).

Editor

IntelliSense on

const user = { name: "Sam", age: 20 };
// Write your code below

Challenge 10 of 12 · Delete a key

Challenge 10 of 12

Delete a key

Instructions

Delete `temp` from `data`.

Editor

IntelliSense on

const data = { temp: 1, keep: 2 };
// Write your code below

Challenge 11 of 12 · Object values

Challenge 11 of 12

Object values

Instructions

Store `Object.values(score)` in `points`.

Editor

IntelliSense on

const score = { a: 1, b: 2 };
// Write your code below

Challenge 12 of 12 · Shorthand properties

Challenge 12 of 12

Shorthand properties

Instructions

Given `name` and `age`, create `person` using property shorthand.

Editor

IntelliSense on

const name = "Leo";
const age = 19;
// Write your code below

Next module