From 859e555e29725df471d8110ad73c303e8a7f03b3 Mon Sep 17 00:00:00 2001 From: Emmanuel Mahuni Date: Thu, 2 Sep 2021 18:26:11 +0200 Subject: [PATCH] fix: falsy returns undefined when it's not in pool (#523) fixes issue #522 it was picking undefined coz index was wrong --- chance.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chance.js b/chance.js index 2b68a0a9..dafcd5e8 100644 --- a/chance.js +++ b/chance.js @@ -148,9 +148,9 @@ Chance.prototype.falsy = function (options) { // return a random falsy value - options = initOptions(options, {pool: [false, null, 0, NaN, '']}) + options = initOptions(options, {pool: [false, null, 0, NaN, '', undefined]}) var pool = options.pool, - index = this.integer({min: 0, max: pool.length}), + index = this.integer({min: 0, max: pool.length - 1}), value = pool[index]; return value;