0
0
Javascriptprogramming~15 mins

Object creation in Javascript - Mini Project: Build & Apply

Choose your learning style9 modes available
Object creation
πŸ“– Scenario: You are creating a simple contact card for a friend. You want to store their name, age, and city in one place.
🎯 Goal: Build a JavaScript object that holds a friend's details and then display the information.
πŸ“‹ What You'll Learn
Create an object with exact properties and values
Add a helper variable for a greeting message
Use the object properties in a template string
Print the greeting message
πŸ’‘ Why This Matters
🌍 Real World
Objects are used to group related information about things like people, products, or places in one place.
πŸ’Ό Career
Understanding how to create and use objects is essential for any JavaScript developer working on websites or apps.
Progress0 / 4 steps
1
Create the friend object
Create an object called friend with these exact properties and values: name set to "Emma", age set to 28, and city set to "New York".
Javascript
Need a hint?

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

2
Add a greeting message variable
Create a variable called greeting and set it to the string "Hello! Here is your friend's info:".
Javascript
Need a hint?

Use const to create a variable and assign the exact string.

3
Create a message using object properties
Create a variable called message and set it to a template string that uses friend.name, friend.age, and friend.city to say: "Emma is 28 years old and lives in New York."
Javascript
Need a hint?

Use backticks ` and ${} to insert variables inside the string.

4
Print the greeting and message
Use two console.log statements to print the greeting and then the message.
Javascript
Need a hint?

Use console.log to print each string on its own line.