fix(curriculum): enhance calorie counter step 45 test flexibility and accuracy (#57101)

This commit is contained in:
hbar1st
2024-12-10 20:56:09 -05:00
committed by GitHub
parent 7802d05fa5
commit 52e9b53593
@@ -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.
@@ -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--