Skip to content

Commit

Permalink
fix(curriculum): enhance calorie counter step 45 test flexibility and…
Browse files Browse the repository at this point in the history
… accuracy (freeCodeCamp#57101)
  • Loading branch information
hbar1st authored Dec 11, 2024
1 parent 7802d05 commit 52e9b53
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dashedName: step-45

Each entry will have a text input for the entry's name, and a number input for the calories. To get a count of the number of entries, you can query by text inputs.

Pass the string `input[type="text"]` to the `querySelectorAll()` method. Remember that you will need to use single quotes for your string, so that you can use double quotes within.
Pass the string `input[type="text"]` to the `querySelectorAll()` method. Remember that if you use single quotes for your string, you must also use double quotes within it (or vice-versa).

This will return a `NodeList` of all the text inputs in the form. You can then access the `length` property of the `NodeList` to get the number of entries. Do this on the same line.

Expand All @@ -18,19 +18,19 @@ This will return a `NodeList` of all the text inputs in the form. You can then a
You should pass the string `input[type="text"]` to the `querySelectorAll()` method.

```js
assert.match(addEntry.toString(), /entryNumber\s*=\s*targetInputContainer\.querySelectorAll\(\s*'\s*input\s*\[\s*type\s*=\s*"text"\s*]\s*'\s*\)/)
assert.match(addEntry.toString(), /entryNumber\s*=\s*targetInputContainer\.querySelectorAll\(\s*("|')\s*input\s*\[\s*type\s*=\s*("|')text\2\s*]\s*\1\s*\)/)
```

You should access the `length` property of your `querySelectorAll()`.

```js
assert.match(addEntry.toString(), /\.querySelectorAll\(\s*'\s*input\s*\[\s*type\s*=\s*"text"\s*]\s*'\s*\)\.length/)
assert.match(addEntry.toString(), /\.querySelectorAll\(.*\)\.(?=(length))(\1$|\1\s*;)/)
```

Your `entryNumber` variable should be the `length` of the `querySelectorAll`.

```js
assert.match(addEntry.toString(), /entryNumber\s*=\s*targetInputContainer\.querySelectorAll\(\s*'\s*input\s*\[\s*type\s*=\s*"text"\s*]\s*'\s*\)\.length/)
assert.match(addEntry.toString(), /entryNumber\s*=\s*targetInputContainer\.querySelectorAll\(\s*("|')\s*input\s*\[\s*type\s*=\s*("|')text\2\s*]\s*\1\s*\)\.(?=(length))(\3$|\3\s*;)/)
```

# --seed--
Expand Down

0 comments on commit 52e9b53

Please sign in to comment.