Simple JS solution using function closures
Refactored
Merge pull request #133 from vasuman/master

JS solution using function closures