coppied first two problems to js