From bb263b87f6ab6f0a94de403386c47fabf3abad5d Mon Sep 17 00:00:00 2001 From: Johnny Reina Date: Mon, 2 Oct 2017 05:08:07 -0500 Subject: Adds check for length param in lorem.word. --- lib/lorem.js | 7 +++++-- 1 file 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); }; -- cgit v1.2.3