Speechify interview question

Refactor then implement a function