I'm trying to learn javascript

You need to assign a function to the key like:

var car = {
  speed:30,

  increaseSpeed: function(milesPerHour) {
    return this.speed + milesPerHour;
  }
};

Then you can call it like:

car.increaseSpeed(100);

Browse More Popular Posts

Leave a Comment