Problem 2 in js