aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lorem.js7
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);
};