There are ways to use map() in this challenge, but not without writing more code than necessary. This is a job for filter().
Take a look at the following minimalist solution. If it makes little sense, try to rewrite it more verbosely. It uses arrow syntax, which allows you to omit curly brackets and the words function and return .
let findElement = (arr, func) => arr.filter(func);
That is great that you came up with a solution, but next time instead of posting full working solutions to the FCC challenge, stick to answering the question(s) of a thread’s original poster. You can do that with hints and suggestions, but please do not post “your” full working solution.
Thank you all for your responses. I will try and honor the moderator’s request to not simply post a solution.
I found the simplest code solution to be with the find() method. You can literally write one line inside the function.
I hope this helps. https://www.w3schools.com/jsref/jsref_find.asp
First, I solved this challenge without using the func (function)… then I went back and after seeing your post I considered I could try to solve this using the Map() function as you suggested… which I solved ,
however, it still involved a For loop due to the fact that the Map() function creates an array instead of a string Sooooo… it looked more like
in order to sort through the array to find the truth value… It is however in the end cleaner apparently to use the filter method suggested after your post. But I thought I would leave this here just in case you still wanted to use map() instead…