Code passes test but console doesn't look right

I have spent the last 30 minutes trying to complete “Functional Programming: Use the filter Method to Extract Data from an Array”

My final solution that passed the test was

var filteredList = watchList.map((a) => {return {
    "title": a.Title, "rating": a.imdbRating 
  }});
filteredList = filteredList.filter(a => {
  return (a["rating"] >= 8 )});

console.log(filteredList);

I am lucky I ran the tests in exasperation because the console was displaying

[object Object],[object Object],[object Object],[object Object]

my question is this: Is my code wrong or should I get used to the console not displaying objects after map/filter being applied?

Thank you

What you’re seeing is the console showing you what it is that you are returning - it’s not to do with using map or filter. console.log(JSON.stringify(filteredList)) is generally very useful when logging objects so you see a string representation. Note this is what appears in my console, most browsers should allow you to inspect what each object is in detail:

Screenshot%20from%202018-09-24%2023-56-19

1 Like

Thank you for your answer! Adding stringify to my tool belt!

1 Like

It’s very useful for logging stuff so you can quickly see what you’re looking at - the non-stringified version is normally more useful, as you can drill into the object in the console, but to just see straightaway what is coming back, stringify is invaluable

console.table() is also kinda neat, but I don’t think it works with the FCC console.

console.table(filteredList);