Question: in javascript Write a function called filterHeros that uses the .filter() method ( 15 pts ) The filterHeros function MUST use the .filter() method The
in javascript
Write a function called filterHeros that uses the .filter() method (15 pts)
The filterHeros function MUST use the .filter() method
The filterHeros accepts an array of objects as an argument
The filterHeros determines which are heros and creates an array of strings that contains only the hero's name
The filterHeros returns the array of hero names.
Example:
filterHeros([ { name: 'Spider-Man', isHero: true }, { name: 'Thor', isHero: true }, { name: 'Thanos', isHero: false }, { name: 'Black Panther', isHero: true }, { name: 'Loki', isHero: false }, { name: 'Captain Marvel', isHero: true }, { name: 'Silver Surfer', isHero: true }, { name: 'Magneto', isHero: false }, { name: 'Venom', isHero: false } ])
EXPECTED OUTPUT (array of strings): ['Spider-Man', 'Thor', 'Black Panther', 'Captain Marvel', 'Silver Surfer']
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
