JSFiddle - React, Tailwind, and code Playground

by Nickolas Smiley

HTML

<!DOCTYPE html>
<html>
<head>
    <title></title>
   <meta charset="utf-8" />
    <script type="text/javascript">
        var list = null;

        function createList() {
            var value = document.getElementById("LinkName").value;
            list = new List(value);
            document.getElementById("demo").innerHTML = list.print();
        }


        function addNode() {
            var value = document.getElementById("LinkName").value;
            list.addNode(value,list.last);
            document.getElementById("demo").innerHTML = list.print();
        }


        function Node(_value, _last) {
            this.value = _value; 
            this.last = _last; 
            this.next = null; 
            return this; 
        }

        Node.prototype.asString = function () {
            return "Node: " + this.value + "<br/>";
        }

        function List(_value) { 
            this.length = 1;
            this.head = new Node(_value, null); 
            this.last = this.head; 
        }

        
        List.prototype.addNode = function (_value,_last) {
            var node = new Node(_value, _last); 

            if (this.length) { 
                this.last.next = node; 
                node.last = this.last; 
                this.last = node; 
            } else {
                this.head = node;
                this.last = node;
            }

            this.length++;
        }


        List.prototype.print = function () {
            var s = "";
            var n = this.head;

            while (n != null) {
                s += n.asString();
                n = n.next;
            }

            return s;
        }

    </script>
</head>
<body>
    <br/><br />
    <input type="button" id="CreateList" value="Create a new List" onClick="createList();" />
    <br /><br /> Name of New Node:
    <input id="LinkName" Value="New Node" />
    <input type="button" id="AddLink" value="Add a new Node to the List" onClick="addNode();" />
    <p...