I don’t know why this don’t work, because I saw the result need to be a array:
ratings
should equal[{"title": "Inception", "rating": "8.8"}, {"title": "Interstellar", "rating": "8.6"}, {"title": "The Dark Knight", "rating": "9.0"},{"title": "Batman Begins", "rating": "8.3"}, {"title": "Avatar", "rating": "7.9"}]
so I just:
let movies = [];
but seems it doesn’t work :
const ratings = watchList.map(movie => {
let movies = [];
movies["title"] = movie["Title"];
movies["rating"] = movie["imdbRating"]
return movies;
});
Output
[[],[],[],[],[]]
but when I change for this:
const ratings = watchList.map(movie => {
let movies = {};
movies["title"] = movie["Title"];
movies["rating"] = movie["imdbRating"]
return movies;
});
It passed!
I dont’t get it…
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Challenge: Use the map Method to Extract Data from an Array
Link to the challenge: