My output looks the same as the expected result, but still fails to pass the 4th condition of the module.
// Only change code below this line
var mapList = [];
var filteredList = [];
filteredList = watchList.filter(
function(item){
if (Number(item.imdbRating) >= 8) {
return {'title': item.title, 'rating': item.imdbRating}
}
}
);
mapList = filteredList.map(function(item) {
return {'title': item.Title, 'rating': item.imdbRating}
});
var number = 33;
String(number);
var number2 = 11;
number.toString(number2);
// Only change code above this line
console.log(mapList);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.
Challenge: Use the filter Method to Extract Data from an Array
Thank you for the reply! Yes, I realized this much later myself after I paid more attention to the question. I was passing the return value to another variable instead of filteredList. The confusion came about because I used the filteredList variable as a placeholder for the filter( ) function which I then pass to the map( ) function. Anyway, thanks heaps.
Yeah, I tried string( ) too but it didn’t work (at least for the exercise, works on REPL). Also, I wanted to avoid double conversions(unsafe practice imo) so I only converted the variable for the sake of comparison to >= 8, and leave the output as it is. Thanks.