def find_shortest(str)
# 實作內容
end
# 今天開始需要用 rspec 執行測試檔
RSpec.describe do
it "找出最短的字" do
expect(find_shortest("bitcoin take over the world maybe who knows perhaps")).to be 3
expect(find_shortest("turns out random test cases are easier than writing out basic ones")).to be 3
expect(find_shortest("lets talk about javascript the best language")).to be 3
expect(find_shortest("i want to travel the world writing code one day")).to be 1
expect(find_shortest("Lets all go on holiday somewhere very cold")).to be 2
end
end
def find_shortest(str)
str.split(" ").map { |s| s.length }.min
end
def find_shortest(str)
str.split(" ").sort_by { |s| s.length }.first.length
end
(第一次寫的比龍哥短 YA)