Pregunta de entrevista de AutoNation

I was given a problem to solve it with code (Javascript)