Faker.js: Random word (singular) sometimes returns more than one word

Created on 25 Jun 2018  路  6Comments  路  Source: Marak/faker.js

Since there are two methods .random.word() and .random.words() I would expect the first one to only include a singular word, but it sometimes generates more than one word.

Most helpful comment

Anyone else wasting time on this?
faker.random.word().split(" ")[0]

All 6 comments

Any idea why this is the case? A PR would be welcomed.

An example would be when the randomly selected word method is commerce.productName as that method returns a string of three words.

Probably the easiest way to patch the random module is to split the returned value from random.word on the space character and then select a random item from the created array.

This way we can use multiple api methods internally for generating words and guarantee only a single word in returned.

The PR for this should be relatively easy if anyone wants to try.

still not resolved... ever 3-4 times we get what always seems to be a 3 word combo

Anyone else wasting time on this?
faker.random.word().split(" ")[0]

Just use faker.lorem.word()

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  4Comments

developdeez picture developdeez  路  5Comments

marcelorl picture marcelorl  路  4Comments

minhchu picture minhchu  路  3Comments

HoustonBass picture HoustonBass  路  6Comments