faker.js addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import faker from 'faker' ; | |
function fakeOrg(){ | |
const namePersonOrOrg = (Math.random() < 0.5) | |
? faker.name.firstName() +' '+ faker.name.lastName() | |
: faker.company.companyName() | |
console.log(namePersonOrOrg) | |
return { | |
name: namePersonOrOrg, | |
// card: faker.helpers.userCard(), | |
// 'first name': faker.name.firstName(), | |
// 'last name': faker.name.lastName(), | |
// 'title': faker.name.title(), | |
'phone': faker.phone.phoneNumber(), | |
'homepage': faker.internet.url(), | |
// 'avatar': faker.internet.avatar(), | |
'address': faker.address.streetAddress(), | |
'address 2 (optional)': faker.address.secondaryAddress(), | |
'city': faker.address.city(), | |
'state': faker.address.state(), | |
'zip code': faker.address.zipCode(), | |
} | |
} | |
function repeatFunctionIntoArr(func, count){ | |
let outputObj = [] | |
for (let i=0; i< count; i++) { | |
outputObj.push(func()) | |
} | |
return outputObj | |
} | |
console.log(repeatFunctionIntoArr(fakeOrg, 3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment