fix(curriculum): typo - replaced data with dessert (#53172)

This commit is contained in:
Ketan Sahu
2024-01-14 13:00:28 +05:30
committed by GitHub
parent a0dd636763
commit e9e80a7acb

View File

@@ -9,11 +9,11 @@ dashedName: step-24
You now have a small bug. When you try to access a property of an object and the property doesn't exist, you get `undefined`. This means if the dessert isn't already present in the `totalCountPerProduct` object, you end up trying to add `1` to `undefined`, which results in `NaN`.
To fix this, you can use the `||` operator to set the value to `0` if it doesn't exist. Wrap your right-hand `totalCountPerProduct[data.id]` in parentheses, and add `|| 0` to the end of the expression.
To fix this, you can use the `||` operator to set the value to `0` if it doesn't exist. Wrap your right-hand `totalCountPerProduct[dessert.id]` in parentheses, and add `|| 0` to the end of the expression.
# --hints--
You should wrap your right-hand `totalCountPerProduct[data.id]` in parentheses.
You should wrap your right-hand `totalCountPerProduct[dessert.id]` in parentheses.
```js
const cart = new ShoppingCart();