Skip to content

Instantly share code, notes, and snippets.

@gatesakagi
Last active June 21, 2017 17:20
Show Gist options
  • Save gatesakagi/d1b2a8da96fb2333e620a231f35697c9 to your computer and use it in GitHub Desktop.
Save gatesakagi/d1b2a8da96fb2333e620a231f35697c9 to your computer and use it in GitHub Desktop.
保哥JS練習
/*
請完成以下 API 設計,讓你的程式可以執行以下程式碼,
並且得到預期的結果。串接 add 的次數沒有上限,最後一個 API 是 result() 才會回傳結果。
$(1).add(2).add(3).add(99).result() === 105
$(1).add(2).add(3).result() === 6
*/
var $ = function(num) {
return {
add: function(numadd) { return $(num+numadd); },
result: function() { return num; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment