Hello, I’ve decided to start contributing to the open source code base, I picked an issue, wrote my first line of code, ran the rest for it, and it failed one of the tests. Here is the error:
Here is the content under the
# --hints-- heading:
# --hints-- `total` should be declared and initialized to 0. ```js assert(code.match(/(var|let|const)\s*?total\s*=\s*0.*?;?/)); ``` `total` should equal 20. ```js assert(total === 20); ``` You should use a `for` loop to iterate through `myArr`. ```js assert(/for\s*\(/g.test(code) && /myArr\s*\[/g.test(code)); ``` You should not attempt to directly assign the value 20 to `total`. ```js assert(!__helpers.removeWhiteSpace(code).match(/total[=+-]0*[1-9]+/gm)); ``` You should be using the elements of `myArr` to update `total`. ```js assert(!__helpers.removeWhiteSpace(code).match(/total[+=-]+\S*myArr\[\w[\w\d]*\]/gm)); ```
The last assertion and the hint above it is what I added:
You should be using the elements of `myArr` to update `total`. ```js assert(!__helpers.removeWhiteSpace(code).match(/total[+=-]+\S*myArr\[\w[\w\d]*\]/gm)); ```
It seems like the lines I added are formatted the same way as the other assertions, so I’m not sure why that test failed.
Note: the issue this is supposed to be for is Challenge: Iterate through an array with a for loop (Make test and requirements stricter) #45041 (I know there is already a PR for this issue, that happened while I was still trying to figure out how this all works, but I still want to work through this problem in order to understand what’s going on before moving on to a different issue.)