fix: fixed regex for validating newlines in for loops (#38180)

pull/38077/head
Hassaan Pasha 2020-02-10 05:43:43 +05:00 committed by GitHub
parent 3e5963b2a7
commit 80ba943ca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -40,7 +40,7 @@ tests:
- text: Your code should use the <code>filter</code> method.
testString: assert(code.match(/\.filter/g));
- text: Your code should not use a <code>for</code> loop.
testString: assert(!code.match(/for\s*?\(.+?\)/g));
testString: assert(!code.match(/for\s*?\([\s\S]*?\)/g));
- text: '<code>filteredList</code> should equal <code>[{"title": "Inception","rating": "8.8"},{"title": "Interstellar","rating": "8.6"},{"title": "The Dark Knight","rating": "9.0"},{"title": "Batman Begins","rating": "8.3"}]</code>.'
testString: 'assert.deepEqual(filteredList, [{"title": "Inception","rating": "8.8"},{"title": "Interstellar","rating": "8.6"},{"title": "The Dark Knight","rating": "9.0"},{"title": "Batman Begins","rating": "8.3"}]);'

View File

@ -41,7 +41,7 @@ tests:
- text: The <code>watchList</code> variable should not change.
testString: assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron");
- text: Your code should not use a <code>for</code> loop.
testString: assert(!removeJSComments(code).match(/for\s*?\(.*?\)/));
testString: assert(!removeJSComments(code).match(/for\s*?\([\s\S]*?\)/));
- text: Your code should use the <code>map</code> method.
testString: assert(code.match(/\.map/g));
- text: <code>ratings</code> should equal <code>[{"title":"Inception","rating":"8.8"},{"title":"Interstellar","rating":"8.6"},{"title":"The Dark Knight","rating":"9.0"},{"title":"Batman Begins","rating":"8.3"},{"title":"Avatar","rating":"7.9"}]</code>.

View File

@ -65,7 +65,7 @@ tests:
- text: The <code>getRating(watchList)</code> should equal 8.675.
testString: assert(getRating(watchList) === 8.675);
- text: Your code should not use a <code>for</code> loop.
testString: assert(!code.match(/for\s*?\(.*\)/g));
testString: assert(!code.match(/for\s*?\([\s\S]*?\)/g));
- text: Your code should return correct output after modifying the <code>watchList</code> object.
testString: assert(getRating(watchList.filter((_, i) => i < 1 || i > 2)) === 8.55);