Object entries
π Scenario: You have a small online store. You keep a list of products and their prices in an object.You want to see each product with its price printed out clearly.
π― Goal: Build a program that uses Object.entries() to get product names and prices, then prints each product with its price.
π What You'll Learn
Create an object called
products with exact entries: 'apple': 1.2, 'banana': 0.5, 'orange': 0.8Create a variable called
entries that stores Object.entries(products)Use a
for loop with variables product and price to iterate over entriesPrint each product and price in the format:
Product: apple, Price: 1.2π‘ Why This Matters
π Real World
Objects are used to store related data like product lists, user info, or settings in many programs.
πΌ Career
Understanding how to work with objects and their entries is essential for web development and JavaScript programming jobs.
Progress0 / 4 steps