problem 1 in javascript