JSFiddle - React, Tailwind, and code Playground

by karin

HTML

<p id="test"></p>
<p id="test2"></p>

JavaScript

function Person(first, last) {
    this.first = first;
    this.last = last;
}
Person.prototype.fullName = function () {
    return this.first + ' ' + this.last;
};
Person.prototype.fullNameReversed = function () {
    return this.last + ', ' + this.first;
};
Person.prototype.allCaps = function () {
    return this.first.toUpperCase();
}
String.prototype.reversed = function () {
    var st = "";
    for (var i = this.length - 1; i >= 0; i--) {
        st += this[i];
    }
    return st;
};

var s = new Person("Simon", "Willison");
document.getElementById("test").innerHTML = s.first.reversed();


Person.prototype.toString = function() {
    return this.fullName();
}
document.getElementById("test2").innerHTML = s;