freeCodeCamp: Stacked Methods Do Not Pass with removeJSComments

Challenge: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/functional-programming/use-the-filter-method-to-extract-data-from-an-array

Forum post: https://forum.freecodecamp.org/t/bug-found-in-this-challenge/458226

Is some part of the code processing chain causing this challenge to fail with the following code?

This fails

var filteredList = watchList.map(movie => ({
   title: movie["Title"],
   rating: movie["imdbRating"]
}))
.filter(r => {
  return parseFloat(r.rating) >= 8.0;
})

This passes:

var filteredList = watchList.map(movie => ({title: movie["Title"],rating: movie["imdbRating"]})).filter(r => {
  return parseFloat(r.rating) >= 8.0;
})

The match for .filter is failing. But it doesn’t seem to me like it should be the regex that is the issue assert(code.match(/\.filter/g)); so maybe we inadvertently broke something, somehow?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

@Sembauke Thank you, for keeping up with this. I was a bit out of the loop with what was happening between this issue and the Safari issue. I will close this, once tested on .dev

@ShaunSHamilton This should get fixed with https://github.com/freeCodeCamp/freeCodeCamp/pull/42254 which is a comment removal implementation using our own fork of the strip-comments lib.

One option would be to keep a copy of the original user code around as another variable. Would that help at all?

Unfortunately I don’t think Babel can only remove comments with zero side-effects.

@gikf thanks for the list.

I might go ahead and look in to the option the generator has to not add white-space for formatting.