Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started