1World interview question

Javascript related logic