Uber interview question

Write a function that returns values randomly, according to their weight.