Beginner question

Hello, I am really new to JavaScript and was just wondering why this code throws an error.
And also what can I do to make it so when I put “raw” after robot.material I get “Iron” and if I put “fuel” I get “2 L”

const robot = {
fuel: “2 L”,
raw: “Iron”,
material(prop) {
return this.prop
}
}
console.log(robot.material(raw))

Hi zolteq,

You’ll have to make the following changes:

const robot = {
  fuel: "2 L",
  raw: "Iron",
  material(prop) {
    return this[prop]
  }
}
console.log(robot.material("raw"))

So when you call the method, you have to surround your parameter in quotes, and in the method itself, you have to return this[prop].