So I've been working through Freecodecamp's courses. I've come across this piece of code in an example:
const person = {
name: "Taylor",
sayHello: function() {
return `Hello! My name is ${this.name}.`;
}
};
In this situation, why has "sayHello" been made a function? Why not simply write:
sayHello: `Hello! My name is ${this.name}.`
Wouldn't that return the same thing?
Apologies for any common sense mistakes here, I'm pretty new to all of this.