Problem 1 in JavaScript.