Problem 3 in js