JSFiddle - React, Tailwind, and code Playground

by Wentz Wu

HTML

<ul id="list"></ul>

JavaScript

var Friend = function (name, age) {
    this.name = name;
    this.age = age;
};

Friend.prototype.addAge = function (year) {
    this.age += year;
    return this.age;
};

var bill = new Friend("bill", 30);
var jack = new Friend("jack", 20);

var billAge = bill.addAge(13);
output(billAge);

/*********helpers*********/
function output(item) {
    var list = document.getElementById("list");
    var listItem = document.createElement("li");
    listItem.textContent = item;
    list.appendChild(listItem);
}