fix: fixed regex for validating newlines in for loops (#38180)
This commit is contained in:
		| @@ -40,7 +40,7 @@ tests: | |||||||
|   - text: Your code should use the <code>filter</code> method. |   - text: Your code should use the <code>filter</code> method. | ||||||
|     testString: assert(code.match(/\.filter/g)); |     testString: assert(code.match(/\.filter/g)); | ||||||
|   - text: Your code should not use a <code>for</code> loop. |   - 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>.' |   - 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"}]);' |     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"}]);' | ||||||
|  |  | ||||||
|   | |||||||
| @@ -41,7 +41,7 @@ tests: | |||||||
|   - text: The <code>watchList</code> variable should not change. |   - text: The <code>watchList</code> variable should not change. | ||||||
|     testString: assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron"); |     testString: assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron"); | ||||||
|   - text: Your code should not use a <code>for</code> loop. |   - 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. |   - text: Your code should use the <code>map</code> method. | ||||||
|     testString: assert(code.match(/\.map/g)); |     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>. |   - 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>. | ||||||
|   | |||||||
| @@ -65,7 +65,7 @@ tests: | |||||||
|   - text: The <code>getRating(watchList)</code> should equal 8.675. |   - text: The <code>getRating(watchList)</code> should equal 8.675. | ||||||
|     testString: assert(getRating(watchList) === 8.675); |     testString: assert(getRating(watchList) === 8.675); | ||||||
|   - text: Your code should not use a <code>for</code> loop. |   - 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. |   - 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); |     testString: assert(getRating(watchList.filter((_, i) => i < 1 || i > 2)) === 8.55); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user