Problem 1 Solution - JavaScript