Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Challenge: Modify and Extend an Object | Fundamentals of JavaScript Objects
JavaScript Data Structures

bookChallenge: Modify and Extend an Object

Task

You're given an object, student, representing a student's information. Your task is to modify existing properties and add new properties.

  • Modify the student's age to be 21.
  • Add a new property called grade and set it to "A".
12345678910111213
const student = { name: "Pauline Reilly", age: 24, major: "Humanities", }; // Task 1: Modify `age` to `21` ___ = ___ console.log(student.age); // Output: 21 // Task 2: Add a new property `grade` ___ = ___ console.log(student.grade); // Output: A
copy

Expected output:

21
A
  1. To modify a property's value, use assignment with dot notation.
  2. To add a new property, use the assignment with dot notation, providing the property name and value.
12345678910111213
const student = { name: "Pauline Reilly", age: 24, major: "Humanities", }; // Task 1: Modify `age` to `21` student.age = 21; console.log(student.age); // Output: 21 // Task 2: Add a new property `grade` student.grade = "A"; console.log(student.grade); // Output: A
copy

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 8

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

Awesome!

Completion rate improved to 2.27

bookChallenge: Modify and Extend an Object

Scorri per mostrare il menu

Task

You're given an object, student, representing a student's information. Your task is to modify existing properties and add new properties.

  • Modify the student's age to be 21.
  • Add a new property called grade and set it to "A".
12345678910111213
const student = { name: "Pauline Reilly", age: 24, major: "Humanities", }; // Task 1: Modify `age` to `21` ___ = ___ console.log(student.age); // Output: 21 // Task 2: Add a new property `grade` ___ = ___ console.log(student.grade); // Output: A
copy

Expected output:

21
A
  1. To modify a property's value, use assignment with dot notation.
  2. To add a new property, use the assignment with dot notation, providing the property name and value.
12345678910111213
const student = { name: "Pauline Reilly", age: 24, major: "Humanities", }; // Task 1: Modify `age` to `21` student.age = 21; console.log(student.age); // Output: 21 // Task 2: Add a new property `grade` student.grade = "A"; console.log(student.grade); // Output: A
copy

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 8
some-alt