I want to build an object from two arrays, and that object should have a unique key name for each distinct value of the first array, and a randomly chosen value from the second which is also unique.
var keyNames = ['a','b','a','c','a']
var valuesToPickFrom = ['foo', 'bar', 'baz', 'qux', 'quux', 'waldo', 'fred']
Ie, the desired end result is:
{ 'a':'foo', 'b':bar', 'c':'baz' } // each value is unique
But not:
{ 'a':'foo', 'b':bar', 'c':'bar' } // repeated value, no good
How can this be done?