Domanda di colloquio di Indeed

How would you do this in javascript?