When I try to assign getUnit's return value to the inputUnit property, my script throws the error "this.getUnit is not a function". Can anyone help?
function ConvertHandler(initialString) {
this.inputUnit = this.getUnit(initialString); // Error here
this.inputNum = this.getNum(initialString);
this.returnedUnit = this.getReturnUnit(this.inputUnit);
this.returnedNum = this.convert();
this.getNum = function(input) {
return input.match(/((\d*\.?\d+)*(\/?)(\d*\.?\d+))/igm);
};
this.getUnit = function(input) {
return input.match(/[A-Za-z]+$/i);
};
}
var a = new ConvertHandler('4mi');
console.log(a.spellOutUnit());