Docs: Define functions used in loop examples (#4653)
Docs: Define functions used in loop examples (#4653)

* Cherrypick changes from messy branch

* Reorder function defs

cosmicexplorer/coffeescript,AndersonFirmino/coffeescript,shreeve/coffeescript,AndersonFirmino/coffeescript,jiangmiao/toffee-script,jiangmiao/toffee-script,jashkenas/coffeescript,xixixao/coffee-script,jiangmiao/toffee-script