Problem 12 in js