Question d’entretien chez Indeed

How would you do this in javascript?