Porting coffeescript to javascript