Added a fully functional JavaScript solution.

No state required (it's the Libertarian dream...).