Skip to content

Commit

Permalink
fix: falsy returns undefined when it's not in pool (#523)
Browse files Browse the repository at this point in the history
fixes issue #522
it was picking undefined coz index was wrong
  • Loading branch information
emahuni committed Sep 2, 2021
1 parent 79ab2d9 commit 859e555
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 859e555

Please sign in to comment.