Meta Interview Question

optimize a function and a js related question.