Walmart interview question

Javascript coding algorithm in whiteboarding