Pergunta de entrevista da empresa Visibly

Implement a function that alternates returning the first and last element of a list until the list is empty.