JSFiddle - React, Tailwind, and code Playground

by Tori Hoelscher

HTML

The variables that this list will be choosing from is: <br>
 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^*(),./;'\[]}{|:?><

 Random List<br/>
<div id="output1"></div>
<br/>Hash List<br/>
<div id="output2"></div>
<br/> Sort Hash List <br/>
<div id="output3"></div>

JavaScript

var list = new List();
var indexes = [];


function Node(_contentA, _contentB) {
    this.contentA = _contentA; 
    this.contentB = _contentB; 
    this.source = null; 
    this.next = null; 
    this.last = null; 
    return this; 
}

function List() {
    this.bottom = null; 
    this.top = null; 
    this.length = 0;

    this.push = function(_contentA, _contentB) {
        
        if (this.bottom == null) {
            this.bottom = new Node(_contentA, _contentB);
            this.top = this.bottom;

            this.length++;

            return this;
        }

        else {
          
            var addedNode = new Node(_contentA, _contentB);
            addedNode.last = this.top; 
            this.top.next = addedNode; 
            this.top = addedNode; 
            this.length++;

            return this;
        }
    }
    

    this.contentAtoString = function() {
        var str = "";
        var node = this.bottom;

        while (node != null) {
            str += node.contentA + " ";
            node = node.next;
        }
        
    return str;
    }
    
        this.toString = function() {
        var str = "";
        var node = this.bottom;

        while (node != null) {
            str += node.contentA + " " + node.contentB + "<br>";
            node = node.next;
        }
        
    return str;
    }
}

List.prototype.create = function() {
    var n = 10;
    var node = this.bottom;
    for (var i = 1; i <= n; i++) {
        this.push(randomString());
    }
    document.getElementById("output1").innerHTML += this.contentAtoString();
}

List.prototype.hash = function() {
    node = this.bottom;
    
    while (node != null) {
    node.contentB = djb2Hash(node.contentA);
    node.source = node.contentA;
    node = node.next;
    }

    document.getElementById("output2").innerHTML += this.toString();
}

List.prototype.copytoArray = function() {
    var node = this.bottom;
    var i = 0;
    while (node != null) {
        indexes[i] =...