From 4fd893c39d95a60345b2f5ca7109122d5bebbf04 Mon Sep 17 00:00:00 2001 From: Johnny Reina Date: Thu, 27 Jul 2017 21:32:05 -0500 Subject: Adds length filter to lorem.word() --- lib/lorem.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') 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); }; /** -- cgit v1.2.3