알고리즘 71 - Friend or Foe?

jabae·2021년 11월 1일
0

알고리즘

목록 보기
71/97

Q.

Make a program that filters a list of strings and returns a list with only your friends name in it.

If a name has exactly 4 letters in it, you can be sure that it has to be a friend of yours! Otherwise, you can be sure he's not...

Ex: Input = ["Ryan", "Kieran", "Jason", "Yous"], Output = ["Ryan", "Yous"]

i.e.

friend ["Ryan", "Kieran", "Mark"] shouldBe ["Ryan", "Mark"]

A)

function friend(friends){
  return friends.filter(el => el.length === 4)
}
profile
it's me!:)

0개의 댓글