// Add your code below this line
var filteredList = [];
var finishedArray = [];
function filterByRating(item){
if(Number(item.imdbRating) >= 8){
return true;
}
return false;
}
function filterOutput(item){
return [{title: item.Title, rating: item.imdbRating}];
}
filteredList = (watchList.filter(filterByRating));
finishedArray = (filteredList.map(filterOutput));
// Add your code above this line
console.log(finishedArray);
I feel like I am super close with this. I don’t fully understand .map and .filter. I based this code off of the examples of the methods on w3schools and MDNwebDocs.
The way my code works now, its returning the correct information the correct way except it is an array of arrays.
I don’t know what I am doing wrong to make it do an array of arrays. I understand that map and filter both create new arrays while keeping the one it is working off of untouched. My filter works just fine creating an array of 4 items. I do map the same way as I do filter and i get an array of 1 item arrays.
I have tried using push in different ways:
finishedArray.push(filteredArray.map(filterOutput);
and I tried:
filteredArray.map(finsihedArray.push(filteredOutput);
and both of those resulted in an error.