Problem 5 in js