diff options
| author | Johnny Reina <[email protected]> | 2017-10-02 05:08:07 -0500 |
|---|---|---|
| committer | Johnny Reina <[email protected]> | 2017-10-02 05:08:07 -0500 |
| commit | bb263b87f6ab6f0a94de403386c47fabf3abad5d (patch) | |
| tree | fe62ee106a52715eb780d9e0064170dd4919c137 | |
| parent | 0bc3b03beb38a50cd5099e6081b0ab7f62638f36 (diff) | |
| download | faker-bb263b87f6ab6f0a94de403386c47fabf3abad5d.tar.xz faker-bb263b87f6ab6f0a94de403386c47fabf3abad5d.zip | |
Adds check for length param in lorem.word.
| -rw-r--r-- | lib/lorem.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/lorem.js b/lib/lorem.js index 32e89959..16b1a4bd 100644 --- a/lib/lorem.js +++ b/lib/lorem.js @@ -11,10 +11,13 @@ var Lorem = function (faker) { * generates a word of a specified length * * @method faker.lorem.word - * @param {number} length + * @param {number} length length of the word that should be returned */ self.word = function (length) { - var properLengthWords = faker.definitions.lorem.words.filter(function(word) { return word.length === num; }); + var hasRightLength = function(word) { return word.length === length; }; + var properLengthWords = typeof length == 'undefined' + ? faker.definitions.lorem.words + : faker.definitions.lorem.words.filter(hasRightLength); return faker.random.arrayElement(properLengthWords); }; |
