problem 6 in js