Home › Forums › JavaScript › whats wrong with this funtion? › Reply To: whats wrong with this funtion?
October 22, 2013 at 4:17 pm
#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.