Kata Practice - Sum of two lowest positive integers (JavaScript)

Kata Practice - Sum of two lowest positive integers (JavaScript)

這個系列會把自己練習過的 Kata 題目記錄下來,希望除了記錄的性質以外也能夠觀察自己撰寫程式邏輯的進化過程。如果有幸看到這邊的話也可以參考一下,再到 Codewars 的網站註冊一個帳號試著玩看看,自己蠻喜歡整個網站的得分和排行榜設定,會讓人越寫越有成就感喔!

題目

Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 positive integers. No floats or non-positive integers will be passed.

For example, when an array is passed like [19, 5, 42, 2, 77], the output should be 7.

[10, 343445353, 3453445, 3453545353453] should return 3453455.

自己的解法

1

解題脈絡

其他人的解法

1

選擇記錄這個解法的原因

觀念釐清

那我們就下次見ʘ‿ʘ

評論