What is your hint or solution suggestion?
First, the maximum string length needs to be found. This is done by using Array.reduce
and a conditional function to test the length of each string compared to the known maximum length.
Then, the Array.filter
method is used to only keep strings which are of maximum length.
Solution 1
var ln = arr => arr.reduce((r,s) => r > s.length ? r : s.length, 0);
const longestString = arr => arr.filter(pl => pl.length == ln(arr));
Challenge: Longest string challenge
Link to the challenge: