problem 8 in js