I think there is a mistake in this statement here

In this tutorial: [https://www.codecademy.com/courses/introduction-to-javascript/lessons/objects/exercises/methods], this is written:

We can include methods in our object literals by creating ordinary, comma-separated key-value pairs. The key serves as our method’s name, while the value is an anonymous function expression.

But this example was given that separates method name from function with colon instead of a comma:

image

Please review and clarify if I am getting it wrong.
Thanks.
@AnatuGreen

When it refers to “comma-separated key-value pairs”, this is a description of the object as a whole. So when it says “key-value pair” this is referring to the key invade, and the value, the function provided. The colon is used to denote which is the key and which is the value. The comma-separated part refers to how you list the key-value pairs. So if you have multiple, these are comma separated, like so:

const killerRobot = {
  name: "Killer Robot",
  health: 10000,
  damage: 500,
  attack: function () {
    console.log(`${name} attacks for ${damage} damage!`);
  }
}

See here that all of the key-value pairs are comma-separated. This is what it’s referring to. Hopefully that clears it up! See the Codebyte below for it in action.

const killerRobot = { name: "Killer Robot", health: 10000, damage: 500, attack: function () { console.log(`${this.name} attacks for ${this.damage} damage!`); } } killerRobot.attack()