Walmart Global Tech interview question

Code a bespoke version of forEach, map, and reduce