Generate an array with random data without using a for loop
Create an array with blanks, and then use .map()
to create users:
const createUsers = (numUsers = 5) => {
return Array(numUsers)
.fill(null)
.map(createUser);
}
Array.from allows you to create an array and initialize it with values returned from a callback function in one step:
const createUsers = (numUsers = 5) => {
return Array.from({length: numUsers}, createUser);
}