Amazon interview question

technical portion of the interview asked me to create a function