Unify Interview Question

You have to solve an algorithm problem based on javascript