I am using the Faker.js library which allows to generate dummy data for many types like name, addresses etc. The library is used like this:
var faker = require('faker');
var random = faker.random.number();
I need to be able to call methods dynamically on faker instance from a string representing the property path.
Example:
Having a string variable with value "name.lastName", I need to be able to call faker like:
faker.name.lastName()
I am able to do call faker like this using hardcoded values but I am having trouble to use a variable instead:
Faker['random']['number']()
Any ideas?
Thank you.