Let's say that I have a list of 5 people's name
let listNames = [Sam, Ash, Moe, Billy, Kenzi]
and I want for each of the names to have properties of doneHomeWork and lazy using class
class Person {
constructor() {
this.doneHomeWork = 0
this.lazy = false
}
}
instead of assigning each names as so :
const Sam = new Person()
const Ash = new Person()
const Moe = new Person()
const Billy = new Person()
const Kenzi = new Person()
I was thinking doing this
listNames.forEach(name => {
name = new Person()
})
However, in my ESLint it's giving me an error
Assignment to function parameter 'name' no-param-reassign
This seems trivial, but for some reason I am having trouble re-factoring this.