Object Entries and fromEntries
Entries from Entries
π¨βπΌ We need to apply a discount to all prices in our catalog and return a new
object with updated values.
π¨ Open
and use the provided
priceBySku fixture:- Create
entriesusingObject.entriesβ expected:[['sku-1', 1299], ['sku-2', 499], ['sku-3', 2500]] - Create
discountedEntriesby transforming each entry's price to 10% off, rounded to the nearest whole number. Expected discounted prices:1169,449, and2250(same sku order) - Create
discountedPricesusingObject.fromEntriesβ expected:{ 'sku-1': 1169, 'sku-2': 449, 'sku-3': 2250 } - Export
entries,discountedEntries, anddiscountedPrices
- π MDN - Object.entries
- π MDN - Object.fromEntries