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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!