From 5f90fc5562c391ad7c5e446ac419aee90be7a8b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Mon, 5 Dec 2016 23:05:54 +0100 Subject: [PATCH] Prevent from being paired with yourself --- SecretSanta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SecretSanta.js b/SecretSanta.js index b7159f9..075b0d8 100644 --- a/SecretSanta.js +++ b/SecretSanta.js @@ -38,7 +38,7 @@ SecretSanta.prototype.generate = function () { this.names.forEach( function ( name ) { - var candidates = _.difference( this.names, name ); + var candidates = _.difference( this.names, [ name ] ); if ( Object.prototype.hasOwnProperty.call( this.blacklists, name ) ) candidates = _.difference( candidates, this.blacklists[ name ] );