We're supposed to do this exercise for webdev class and I can't figure out how to solve it.
We have to create a 'person' object and fill it with random information using a method called randomPerson()
. That part works fine so far.
let person = {
fname: "",
lname: "",
city: "",
street: "",
hobbies: new Array(),
}
After this, we're supposed to create another function that creates 10 of these random person objects and stores them in an array.
This is what I have so far:
let person = {
fname: "",
lname: "",
city: "",
street: "",
hobbies: new Array(),
};
personsArr = new Array();
function persons10() {
for (let i = 0; i < 10; i++) {
// randomPerson() // makes it crash
personsArr.fill(person)
}
}
persons10()
console.log(personsArr)
When I try to run that, the page gets stuck loading and freezes.