Learning Angular and improving my javascript