Pregunta de entrevista de WeShape

How would you optimize the code?