Learn Intermediate OOP by Building a Platformer Game - Step 70

Tell us what’s happening:

I have removed this.x, this.y as these aren’t methods within the constructor. please help as I don’t understand why this code isn’t passing?

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region


class Platform {
  constructor(x, y) {
    this.position = {
      x,
      y,
    };
    this.width = 200;
    this.height = proportionalSize(40);
  }
  draw() {
 ctx.fillStyle = "#acd157";
    ctx.fillRect(x, y, this.width, this.height);

  }
}


// User Editable Region

Your browser information:

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

Challenge Information:

Learn Intermediate OOP by Building a Platformer Game - Step 70

x and y are properties on position and position is a property on this

this.prop.someOtherProp


Also, they are not methods, methods are just functions on an object, or put differently the method is a property on the object. So the name of the method is the key and the function is the value.

const obj = {
  key: () => 'Hello, World!'
}

console.log(obj.key()); // Hello, World!

thank you :slight_smile: I didn’t realise it was to do with the position, thank you :slight_smile: