JS Solution

Pretty simple JS solution.
My shitty solution
Add fourth javascript solution
Actually fifth solution - this stuff moves fast, yo
changed folder
window -> var

oops, leaked this one in when changing folders.
Added very short JS solution based on argument binding. Non-self-mutating!
Add non-mutating solution using Function.bind
Added a fully functional JavaScript solution.

No state required (it's the Libertarian dream...).
Inmatarian's solution in Javascript
Adds jamesism javascript solution
No need for global
Added ES6 JavaScript solution

37 bytes for a single use function.
41 bytes for a multi-use function.
Functional JS using optional arguments

A simple, purely functional solution taking advantage of the fact that JS function arguments are all optional.
Java non-solution
Add Neat version ( http://github.com/FeepingCreature/fcc )
Made the sed solution shorter; the output is less nice but it's still within the rules
define sub to obviate sigil
Simple JS solution using function closures
re-entrant recursively implementation