Help me solve this exercise:
Define a static method within the Person class which, given an object literal as input, instantiates a Person object
class Person {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
static fromObject() {
}
}
const obj = {
firstName: 'Mario',
lastName: 'Rossi'
};
const person = Person.fromObject(obj);
console.log(`${person.firstName} ${person.lastName}`);
I have no idea! First time ever I add a static method to a class in JavaScript. I searched the internet but I still cannot solve it.