WooliesX interview question

How to improve the code