Apcera interview question

Solving a Javascript problem