Robinhood Interview Question

Just a vanilla js coding question.