Cannot use value from previous object property function starting(); when trying to combine in output below; getting NaN for timeTaken(); function. Presumably starting isn't reporting within that function, any suggestions?
starting : function() {
return this.slow * this.driveTime + " mph ";
},
timeTaken : function() {
return this.starting / this.driveTime + " seconds ";
},
document.getElementById("car").innerHTML = car.starting() + car.timeTaken();
Should I rather try to nest both functions in same one function? I'm open to more optimal methods.
Full object code:
var car = {
cruise: "35",
slow: "5",
stop: "0",
driveTime: "4",
starting : function() {
return this.slow * this.driveTime + " mph ";
},
timeTaken : function() {
return this.starting / this.driveTime + " seconds ";
},
};
car.starting()working fine?