Problem 4 in js