Vesttoo interview question

JS - leetcode, some array mapping.