const list = ['Apple', 'Orange', 'Egg']
list.map(item => item[0]).filter(item => item === 'A') //'A'
var options = [
{ name: 'One', assigned: true },
{ name: 'Two', assigned: false },
{ name: 'Three', assigned: true },
];
var reduced = options.reduce(function(filtered, option) {
if (option.assigned) {
var someNewValue = { name: option.name, newProperty: 'Foo' }
filtered.push(someNewValue);
}
return filtered;
}, []);
document.getElementById('output').innerHTML = JSON.stringify(reduced);
<h1>Only assigned options</h1>
<pre id="output"> </pre>
// Only change code below this line
const filteredList = watchList
.filter(({ imdbRating }) => imdbRating >= 8.0)
.map(({ Title: title, imdbRating: rating }) => ({ title, rating }));
// Only change code above this line
console.log(filteredList);
const filteredList = watchList
.filter(movie => {
// return true it will keep the item
// return false it will reject the item
return parseFloat(movie.imdbRating) >= 8.0;
})
.map(movie => {
return {
title: movie.Title,
rating: movie.imdbRating
};
});