Iterating over objects
๐ Scenario: You work in a small shop and have a list of products with their prices stored in an object. You want to check and display each product's price.
๐ฏ Goal: Build a simple program that iterates over an object of products and their prices, then prints each product name with its price.
๐ What You'll Learn
Create an object called
products with exact product-price pairsCreate a variable called
currency to store the currency symbolUse a
for...in loop with variable product to iterate over productsPrint each product and its price with the currency symbol
๐ก Why This Matters
๐ Real World
Shop owners and cashiers often need to list products and prices from a database or object to show customers.
๐ผ Career
Knowing how to iterate over objects is essential for web developers working with data structures and displaying information dynamically.
Progress0 / 4 steps