Function Design Strategy
Source: http://www.ics.uci.edu/~kay/courses/31/design-recipe.html
- Write examples
- Write type contract
- Name the function and parameters
- Write description
- Write function body
- Test examples
/*
(a: Number, b: Number) -> Number
Return the greater of `a` and `b`
Examples
max(1, 2) // => 2
max(2, 2) // => 2
max(2, 1) // => 2
max(-100, 1) // => 1
*/
function max(a, b) {
return a > b ? a : b;
}