JS Solution to Problem 20