알고리즘 76 - Shortest Word

tamagoyakii·2021년 11월 4일
0

알고리즘

목록 보기
76/89

Q.

Simple, given a string of words, return the length of the shortest word(s).

String will never be empty and you do not need to account for different data types.

A)

function findShort(s){
  return s.split(' ').map(el => el.length).reduce((acc, cur) => Math.min(acc, cur))
}

0개의 댓글