diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array.english.md index 20930f7b4f..b7dc5dbd25 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array.english.md @@ -24,13 +24,13 @@ The watchList array holds objects with information on several movie ```yml tests: - text: The watchList variable should not change. - testString: assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", 'The watchList variable should not change.'); + testString: assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron"); - text: Your code should not use a for loop. - testString: assert(!code.match(/for\s*?\(.+?\)/g), 'Your code should not use a for loop.'); + testString: assert(!removeJSComments(code).match(/for\s*?\(.*?\)/)); - text: Your code should use the map method. - testString: assert(code.match(/\.map/g), 'Your code should use the map method.'); + testString: assert(code.match(/\.map/g)); - text: rating should equal [{"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"}]. - testString: assert(JSON.stringify(rating) === JSON.stringify([{"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"}]), 'rating should equal [{"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"}].'); + testString: assert(JSON.stringify(rating) === JSON.stringify([{"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"}])); ``` @@ -170,7 +170,14 @@ console.log(JSON.stringify(rating)); +### After Test +
+```js +const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, ''); +``` + +