make the node.js sample work on Windows

Also, beautify the code and fix some jshint's findings.