Amazon Interview Question

Debug this code so the tests pass