0
0
Javascriptprogramming~10 mins

Accessing object properties in Javascript - Mini Project: Build & Apply

Choose your learning style9 modes available
Accessing object properties
πŸ“– Scenario: You are working on a simple app that stores information about a book. You want to get details like the book's title and author from an object.
🎯 Goal: Learn how to access properties of a JavaScript object using dot notation.
πŸ“‹ What You'll Learn
Create an object with specific properties
Create a variable to hold a property name
Access object properties using dot notation
Print the accessed property values
πŸ’‘ Why This Matters
🌍 Real World
Accessing object properties is a basic skill needed to work with data in JavaScript apps, such as user profiles, product details, or settings.
πŸ’Ό Career
Many programming jobs require working with objects and accessing their properties to manipulate and display data correctly.
Progress0 / 4 steps
1
Create a book object
Create an object called book with these exact properties and values: title set to 'The Great Gatsby', author set to 'F. Scott Fitzgerald', and year set to 1925.
Javascript
Need a hint?

Use curly braces {} to create an object and separate properties with commas.

2
Create a variable for the property name
Create a variable called propertyName and set it to the string 'author'.
Javascript
Need a hint?

Use const to create a variable and assign the string 'author' to it.

3
Access the author property using dot notation
Create a variable called authorName and set it to the value of the author property of the book object using dot notation.
Javascript
Need a hint?

Use dot notation like object.property to get the value.

4
Print the author name
Write a console.log statement to print the value of authorName.
Javascript
Need a hint?

Use console.log(authorName); to print the value.