Insider One interview question

Basic JavaScript knowledge and basic algorithms