idiomatic.js refactorings for chapter 1 and 2