Skip to content

Commit 6e61800

Browse files
authored
fix(curriculum): Shopping Cart optional braces (freeCodeCamp#56691)
1 parent b6c47bf commit 6e61800

File tree

1 file changed

+4
-4
lines changed
  • curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart

1 file changed

+4
-4
lines changed

curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0284532742c1b26c7a052.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ Add your callback function to the `forEach` method. It should take a `btn` param
1414
You should use arrow syntax to add a callback function to the `forEach` method which takes a `btn` parameter.
1515

1616
```js
17-
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*(\(\s*btn\s*\)|btn)\s*=>\s*\{/);
17+
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*(\(\s*btn\s*\)|btn)\s*=>\s*(?:\{|\s*)/);
1818
```
1919

2020
You should add an event listener to the `btn` variable.
2121

2222
```js
23-
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*(\(\s*btn\s*\)|btn)\s*=>\s*\{\s*btn\s*\.\s*addEventListener\s*\(/);
23+
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*(\(\s*btn\s*\)|btn)\s*=>\s*(?:\{\s*btn\s*\.\s*addEventListener\s*\(|\s*btn\s*\.\s*addEventListener\s*\()/);
2424
```
2525

2626
You should listen for a `click` event on the `btn` variable.
2727

2828
```js
29-
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*(?:\(\s*btn\s*\)|btn)\s*=>\s*\{\s*btn\s*\.\s*addEventListener\s*\(\s*('|"|`)click\1\s*,\s*/);
29+
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*(?:\(\s*btn\s*\)|btn)\s*=>\s*(?:\{\s*btn\s*\.\s*addEventListener\s*\(\s*('|"|`)click\1\s*,\s*|\s*btn\s*\.\s*addEventListener\s*\(\s*('|"|`)click\2\s*,\s*)/);
3030
```
3131

3232
You should add an empty callback function to the event listener. Remember to give it an `event` parameter.
3333

3434
```js
35-
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*(?:\(\s*btn\s*\)|btn)\s*=>\s*\{\s*btn\s*\.\s*addEventListener\s*\(\s*('|"|`)click\1\s*,\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/);
35+
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*(?:\(\s*btn\s*\)|btn)\s*=>\s*(?:\{\s*btn\s*\.\s*addEventListener\s*\(\s*('|"|`)click\1\s*,\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)|\s*btn\s*\.\s*addEventListener\s*\(\s*('|"|`)click\3\s*,\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\))/);
3636
```
3737

3838
# --seed--

0 commit comments

Comments
 (0)