JS: replacing alert with console