Properly convert CofeeScript example to Javascript