Stuck on this challenge, using a map to extract data

Hi all,
I hope somebody can help , I really appreciate it.
I’ve been stuck on this challenge for a bit too long now.
My solution seems to return the correct result, but still it will not pass.
Is it not returning the wrong type of object or such ?
Any help would be great, I really want to solve this on my own , and so want to see why my code won’t pass.

Thanks :slight_smile:

ratings= watchList.map(index =>{
	return ("{title:" + index.Title +"," +  "rating:" + index.imdbRating + "}");	
      // return ("{title:" + Object.values(index.Title) +"," +  "rating:" + Object.values(index.imdbRating) + "}");	also seems to work 
});
// I added the second return, as I've tried a lot and none seem to be what's wanted

Challenge: Use the map Method to Extract Data from an Array

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

i dont know why you are appending stuff? there is no need for you to do this, you can just do a normal object like return { title: title, rating: rating }

I tried that too earlier , but it gave the same results, so I went with appending.

I tried this earlier:

return ({ "title": index.Title , "rating": index.rating });	

but it only displays the title values and doesn’t pass either.
When I used:

return ("{title:" + index.Title +"," +  "rating:" + index.imdbRating + "}");	

at least in the FCC console I can see the correct results, even though it doesn’t pass.

I hope someone can help , thanks :slight_smile:

Yes, I suspected something like that.
This worked finally:

return ( {title:index.Title , rating:index.imdbRating} );	

Thanks:)

1 Like

this is also wrong, object doesnt have quotes so “title” would be title

@biscuitmanz It’s completely acceptable, and in some cases necessary, to define object properties wrapped in quotes.

1 Like

yh didnt know that bro, iv only seen it like that in json tbh