Canva interview question

How would you improve efficiency of this implementation?