I have an array of strings.
let people = ['Bill', 'Paul', 'William', 'Francis'];
I want to create random pairs :
Bill -> Paul
Paul -> Francis
William -> Bill
Francis -> William
All couples must be unique and every name in second column can be used only once.
Here is my code but it doesn't work as expected.
let receivers = people.sort(function() { return 0.5 - Math.random() });
for (let i in people)
{
console.log(people[i] +' -> '+ receivers[i]);
}
Anyone suggestions?