Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 600 Bytes

shortest-word.md

File metadata and controls

24 lines (17 loc) · 600 Bytes

Shortest Word 7 Kyu

LINK TO THE KATA - FUNDAMENTALS

Description

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.

Solution

const findShort = s => {
  const words = s.split(/\s+/)
  const wordsSortedAscendingLength = words.sort((a, b) => a.length - b.length)

  return wordsSortedAscendingLength[0].length
}