Dark Mode
Enable Console
friend(friends)
/*
Returns a list of (friend's) names that are filtered
by length - in this case it's the length of four.
*/
friend(["Ryan", "Kieran", "Mark"]);
// ["Ryan", "Mark"]
friend(["John", "Alex", "Robert", "Fred"]);
// ["John", "Alex", "Fred"]
Solution by - Need4Swede
function friend(friends) {
// Return names that are four characters in length
return friends.filter(fname => fname.length === 4)
}
Try it yourself - Codewars Source