Updated js of Question 1