mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-25 02:14:11 -05:00
fix(curriculum): typo - replaced data with dessert (#53172)
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user