JSFiddle - React, Tailwind, and code Playground

by Jeff Santos

HTML

<input type="button" id = "CreateList" value="Create List" onclick="makeList();" />
<br/>
<br/>
Enter Node to be Added:
<input type="textbox" id="aNode" value = ""/>
<input type="button" id = "AdNode" value="Add to List" onclick="addNode();" />
<br/>
<p id="outcome"></p>

JavaScript

var list = null;
var aaNode = new Node("Node A"); 
var bNode = new Node("Node B"); 
var cNode = new Node("Node C"); 
var dNode = new Node("Node D"); 
var eNode = new Node("Node E"); 
var aList = new List("Node A", "Node B" , "Node C" , "Node D" , "Node E");
var s = "";
//var n = this.head;

function makeList() {
 
}

function addNode() {
  var value = document.getElementById("aNode").value;
  list.adNode(value);
  document.getElementById("outcome").innerHTML = list.print();
}

List.prototype.print = function() {
  var s = "";
  var n = this.head;
 
  while (n != null){
     s += n.asString();
     n = n.next;
  }

  return s;
}




function Node(A,B,last) {
this.value = "A";
this.next = Node(B);
this.last = last;
return this;
}

function Node(B,C,A) {
this.value = "B";
this.next = Node(C);
this.last = Node(A);
return this;
}

function Node(C,D,B) {
this.value = "C";
this.next = Node(D);
this.last = Node(B);
return this;
}

function Node(value,E,C) {
this.value = value;
value = "A";
this.next = Node(E);
this.last = Node(C);
return this;
}

function Node(E,next) {
this.value = E;
this.next = next;
//this.last = Node(D);
return this;
}

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

function List(length,A,E){
this.length = length;
this.head = new Node(A); 
this.tail =  Node(E);
}


List.prototype.addNode = function(A, E) {
    var node = new Node(value);
 
    if (this._length) {
        this.tail.next = node;
        node.previous = this.tail;
        this.tail = node;
    } else {
        this.head = node;
        this.tail = node;
    }
 
    this._length++;
     
    return node;
}