fix(curriculum): fix tests for step 43 of shopping cart project (#54631)

This commit is contained in:
Josh
2024-05-07 15:11:30 +01:00
committed by GitHub
parent 62bfd20682
commit 8f9913d02b

View File

@@ -46,14 +46,14 @@ Your `reduce` callback should return the sum of `total` and `item.price`. Use an
```js
const afterCalculateTotal = code.split('calculateTotal')[1];
assert.match(afterCalculateTotal, /\(\s*total\s*,\s*item\s*\)\s*=>\s*total\s*\+\s*item\.price/);
assert.match(afterCalculateTotal, /\(\s*total\s*,\s*item\s*\)\s*=>\s*(?:total\s*\+\s*item\.price|item\.price\s*\+\s*total)/);
```
Your `reduce` call should have an initial value of `0`.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];
assert.match(afterCalculateTotal, /this\s*\.\s*items\s*\.\s*reduce\s*\(\s*\(\s*total\s*,\s*item\s*\)\s*=>\s*total\s*\+\s*item\.price\s*,\s*0\s*\)/);
assert.match(afterCalculateTotal, /this\s*\.\s*items\s*\.\s*reduce\s*\(\s*\(\s*total\s*,\s*item\s*\)\s*=>\s*(?:total\s*\+\s*item\.price|item\.price\s*\+\s*total)\s*,\s*0\s*\)/);
```
# --seed--