JSFiddle - React, Tailwind, and code Playground

by Vince

HTML

<h1>Console below:</h1>
<div id="console">
</div>

JavaScript

var obj = {
    a : function () {
        return Math.round(Math.random() * 10);
    },
    b : function () {
        return this.a() + 30;
    },
    c : 19,
    add : function (n1, n2) {
        return n1 + n2;
    },
    remove : function (n1, n2) {
        return n1 - n2;
    },
    eval: function (a) {
        var n1 = this.a();
        var n2 = this.b();
        var str = "the first number is " + n1 + " and the last number is " + n2 ".\n Both equal " + (n1 + n2);
        return str;
    },
    init: function () {
        document.getElementById('console').innerHTML = this.eval();
    }
};
obj.init();