A confusion in my mind

Hey @codely & @ieahleen,
I don’t want to help in this project instead i want to know that why there is always a function in there as follow:

Bird.prototype = {
numLegs: 2,
eat: function() {
console.log(“nom nom nom”);
},
describe: function() {
console.log("My name is " + this.name);
}
};
why we can’t simply put value to eat and describe property as follow:

Bird.prototype = {
numLegs: 2,
eat = "“nom nom nom”,
describe = “My name is " + this.name”};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36.

Challenge: Change the Prototype to a New Object

Link to the challenge:

Hi @mudassirikram21 ,

I think there are functions to print the strings to the console.

When you take away those functions and only assign values to your keys, it won’t print anything on to the console. It is alright if that’s the functionality you want.

it is not much covered, but this will have different values in those two siuations
the prototype does not have a name property, but if you have the describe function it will get the name property of the object it is used on

1 Like