Pregunta de entrevista de Auction.com

solving a problem using javascript