Hej!
I just did the .reduce challange with what i think should be acceptable code, considering I’m using the .reduce function;
function getRating(watchList){
return watchList
.filter( chris => chris.Director === "Christopher Nolan")
.map(rating => rating.imdbRating)
.map(Number)
.reduce((accu,current) => accu + current)
/watchList.filter( movie => movie.Director === "Christopher Nolan").length
}
However, when i run the tests it fail on the point requiring the user to use the .reduce method
Am i missing something here?
Thanks! <3
Br
E
Your code is fine, this is caused by bug that is worked on (see link below). To make test pass just put all chained methods in the single line with the watchList
.
opened 03:29PM - 11 May 21 UTC
scope: curriculum
I think we (well I) broke Safari support with this PR https://github.com/freeCod… eCamp/freeCodeCamp/pull/41960.
In my defense, I can't test code on Safari and didn't even think about the use of unsupported regex in the library as it has so many weekly downloads on npmjs that I just assumed good browser support.
Here is an issue on the libs Github that seems to confirm it.
https://github.com/jonschlinkert/strip-comments/issues/64
Forum posts:
https://forum.freecodecamp.org/t/invalid-regular-expression-error/459841
https://forum.freecodecamp.org/t/cant-run-test-on-freecodecamp/459842
https://forum.freecodecamp.org/t/syntax-erro-invalid-regular-expression/459834
sanity is correct. You can bandaid fix it by sticking those chained methods on one line.
Not:
watchList
.filter(/* stuff */)
.map(/* stuff */)
.map(/* stuff */)
.reduce(/* stuff */)
but:
watchList.filter(/* stuff */).map(/* stuff */).map(/* stuff */).reduce(/* stuff */)
It’s OK if the editor automatically wordwraps it, just don’t put any whitespace in the chain.
Yes, it’s a bug - they’re looking into it.
system
Closed
November 22, 2021, 10:27am
4
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.