Lyft interview question

Asked to recreate a standard JavaScript function from scratch.