Updated solution for Javascript Exercise2