Только для справки. Подробнее:
Объявление функций в JavaScript
function filterOptions(options) {
return options.filter(i => i.selected);
}
function filterOptions(options) {
return options.filter((i) => i.selected);
}
var options = [
{
name: "Red Pepper",
selected: false,
value: "5.99",
},
{
name: "Garlic",
selected: true,
value: "5.99",
},
{
name: "Tomatoes",
selected: true,
value: "5.99",
},
];
var selectedValues = filterOptions(options);
console.log(selectedValues);
.as-console {
min-height: 100% !important;
}
.as-console-row {
color: blue !important;
}