Pregunta de entrevista de RLDatix

solve an basic algorithm in JavaScript