Problem 17 in js