finish problem 1 in js