雨滴是 FizzBuzz 挑戰稍微複雜一點的版本,也是經典的面試題目喔。
你的任務是把一個數字轉換成對應的雨滴聲。
如果給定的數字:
"Plong"。"PlingPlang"。"34"。jq 小技巧if-then-else 運算式在這個練習中會很有幫助。
範例:
8, 10, 12 | if . < 10 then "\(.) is less than ten"
elif . > 10 then "\(.) is more than ten"
else "\(.) equals ten"
end
輸出:
"8 is less than ten"
"10 equals ten"
"12 is more than ten"