fix: make tests more robust (#37830)

pull/37864/head
Randell Dawson 2019-12-02 15:42:32 -08:00 committed by Manish Giri
parent a68e3ef39d
commit dd2fb28ee0
1 changed files with 3 additions and 3 deletions

View File

@ -11,7 +11,7 @@ forumTopicId: 18216
A common task in JavaScript is to iterate through the contents of an array. One way to do that is with a <code>for</code> loop. This code will output each element of the array <code>arr</code> to the console:
```js
var arr = [10,9,8,7,6];
var arr = [10, 9, 8, 7, 6];
for (var i = 0; i < arr.length; i++) {
console.log(arr[i]);
}
@ -36,8 +36,8 @@ tests:
testString: assert(total === 20);
- text: You should use a <code>for</code> loop to iterate through <code>myArr</code>.
testString: assert(code.match(/for\s*\(/g).length > 1 && code.match(/myArr\s*\[/));
- text: You should not set <code>total</code> to 20 directly.
testString: assert(!code.match(/total[\s\+\-]*=\s*(0(?!\s*[;,]?$)|[1-9])/gm));
- text: You should not attempt to directly assign the value 20 to <code>total</code>.
testString: assert(!code.replace(/\s/g, '').match(/total[=+-]0*[1-9]+/gm));
```
</section>