Find Faker Docs Here: https://www.npmjs.com/package/@faker-js/faker
// Install Faker via command line:
npm install @faker-js/faker --save-dev
// Require it inside of a JS file:
const { faker } = require('@faker-js/faker');
// Print a random email
console.log(faker.internet.email());
// Print a random past date
console.log(faker.date.past());
Please note: In newer versions of node you will get a different looking timestamp output when using console.log(faker.date.past());
, compared to what Colt gets in the lecture. To mimic what he gets, you can use the following: console.log(faker.date.past().toString());
// Print a random city
console.log(faker.address.city());
// We can define a new function
function generateAddress(){ console.log(faker.address.streetAddress()); console.log(faker.address.city()); console.log(faker.address.state()); }
// And then execute that function:
generateAddress();