let heroes = [{
name: 'Bob'
},
{
name: 'Jack'
},
{
name: 'Sara'
}
];
let searchItem = 'Bo';
const visibleHeroes = heroes.filter(hero => {
hero.name.includes(searchItem)
});
console.log(visibleHeroes);
-
let heroes = [ { name: 'Bob' }, { name: 'Bobby' }, { name: 'Sara' } ]; let searchItem = 'Bo'; const visibleHeroes = heroes.filter(hero =>{ hero.name.includes(searchItem) }); console.log(visibleHeroes);– Sergey MischenkoCommented 3 июн. 2018 в 21:57
-
какая ошибка в консоли?– Roman CCommented 3 июн. 2018 в 22:26
Добавить комментарий
|
1 ответ
Arrow functions
- или hero => {return value;}
или hero => value
'use strict';
let heroes = [{
name: 'Bob'
},
{
name: 'Jack'
},
{
name: 'Sara'
}
];
let searchItem = 'Bo';
//
let visibleHeroes = heroes.filter(hero => hero.name.includes(searchItem));
console.log(visibleHeroes);