Uber interview question

Write a script in JavaScript