Pregunta de entrevista de Leopard Tech Labs

asked me to write a javascript function