Edit: I removed the Number()
from the first function just playing around and now it passes all the tests. I guess I’m even more confused now. Why would a string pass the >=8
test?
For anyone not familiar, the goal of this is to return the array of new objects which pass a test. Here is my code:
let mappedList = watchList.map(obj => ({title: obj["Title"], rating: Number(obj["imdbRating"]) }));
console.log(mappedList);
let filteredList = mappedList.filter( obj => obj.rating >= 8);
The console.log()
shows what I expected just fine. filteredList
in shows what I want in the console, but did not pass the final test. After forever trying to figure out why, I think I’ve learned that my code is returning objects whose keys are not in strings. (For example, their expect code shows "title": "Inception"
whereas mine shows title: "Inception"
. Small difference.
So first I guess I’d like to ask if this is in fact the reason I’m not passing the test.
Also, I just can’t figure out how to get keys and values back into strings without messing everything up.
Thanks in advance for any help!