JSFiddle - React, Tailwind, and code Playground

by Tim BĂĽthe

JavaScript

var vatObject = {
    vatValue: '1.0',
    vatNumber: function () {
        return this.vatValue.replace(/\D/g, "");
    },
    countryCode: function () {
        return this.vatValue.substring(0, 2);
    },
    // When I call this function, the function is returned as string.
    fullVat: function () {
        return this.vatNumber() + this.countryCode();
    },
    isValid: function () {
        var objRegExp = /^[a-zA-Z]+$/;
        var isAlphaCountryCode = objRegExp.test(this.countryCode());
        if (!isAlphaCountryCode) {
            return false;
        }
        return true;
    }
};

alert(vatObject.fullVat());