Formatting

Code formatting.
Modifications are in demo.js.
Especially the Fix .cost vs .getCost().
Missing `var` here?