diff options
| author | Johnny Reina <[email protected]> | 2017-07-27 21:32:05 -0500 |
|---|---|---|
| committer | Johnny Reina <[email protected]> | 2017-07-27 21:32:05 -0500 |
| commit | 4fd893c39d95a60345b2f5ca7109122d5bebbf04 (patch) | |
| tree | e01de10b50a2f714f4675b465777eee7344b5a4f /lib | |
| parent | c2031a91a20a23cb517f6ba443fae33af7f67b1f (diff) | |
| download | faker-4fd893c39d95a60345b2f5ca7109122d5bebbf04.tar.xz faker-4fd893c39d95a60345b2f5ca7109122d5bebbf04.zip | |
Adds length filter to lorem.word()
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/lorem.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/lorem.js b/lib/lorem.js index db6aec72..d344de15 100644 --- a/lib/lorem.js +++ b/lib/lorem.js @@ -11,10 +11,11 @@ var Lorem = function (faker) { * word * * @method faker.lorem.word - * @param {number} num + * @param {number} length */ - self.word = function (num) { - return faker.random.arrayElement(faker.definitions.lorem.words); + self.word = function (length) { + var properLengthWords = faker.definitions.lorem.words.filter(function(word) { return word.length === num; }); + return faker.random.arrayElement(properLengthWords); }; /** |
