Updated js of Question 1 (3)