[removed] randomly pair items from array without repeats

前端 未结 5 2123
执笔经年
执笔经年 2021-01-05 09:03

I am trying to make a very basic \"secret santa\" generator as one of my first Javascript projects. I have searched for hours for a solution to this problem but so far noth

5条回答
  •  [愿得一人]
    2021-01-05 09:30

    If you don't need to keep the original array you can remove the names as they get selected and each time you pick a name check that it isn't an empty string before pushing it to the next array.

提交回复
热议问题