Amazon interview question

Debug this code so the tests pass