Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript whats wrong with this funtion? Reply To: whats wrong with this funtion?

#153749
Alen
Participant
function Mph(miles, hours){
  this.miles = miles;
  this.hours = hours;
  this.milesPerHour = milesPerHour;
}

function milesPerHour(){
  return this.miles / this.hours;
}

var car1 = new Mph(100, 2);
alert(car1.milesPerHour()); // 50

Another way of doing it.