JSFiddle - React, Tailwind, and code Playground

by scotp71

HTML

<h2>
Umm Clicker
</h2>

<input type='button' 
id='randomButton' 
value='Click'
onclick='ummms()'/>
<p id = 'whyNot'>
</p>
<p id="out"></p>
<div id="output"></div>

JavaScript

ppfunction LinkedList(){
	this.first = null;
  this.last = null;
  this.length = 0;
}

function Node(){
	this.next = null;
  this.prev = null;
  this.content = null;
}

LinkedList.prototype.enqueue = function(_content) {
	var node = new Node();
  node.content = _content;
  if(this.first == null) {
  	this.first = node; 
    this.last = node;
    this.length = 1;
    return node;
  }
  else if(this.first != null){
  	this.last.prev = node;
    node.next = this.last;
    this.last = node;
    this.length++;
    return node;
  }
  
}
LinkedList.prototype.dequeue = function(){
while(this.first!=null){
	var node = new Node();
  node = this.first;
  this.first = this.first.prev;
  this.length--;
  return node.content;
}
return;
}

LinkedList.prototype.print = function() {
	if (this.first == null) return
  var s = "";
  var node = this.first;
  while (node != null) {
  	s += node.content + ", ";
    node = node.prev;
  }  
	return s;
}

var Q1 = new LinkedList();

function addNode() {
  var val = document.getElementById("v").value;
  Q1.enqueue(val);
  printDisplay(val); 
}
var text = "";
function printDisplay(k){
	
  text += "Process " + Q1.length + " duration: " + k + "<br/>";
	document.getElementById("out").innerHTML = text;
}

function dequeueNode(){
  var i = Q1.length;
  var P1BT = parseInt(Q1.dequeue());
  var proccessNum = 1;
  var AT = 0;
  var P1CT = AT + P1BT;
  var P1TAT = P1CT - AT;
  var P1WT = P1TAT - P1BT;
  var totWT = P1WT;
  var totTAT = P1TAT;
  var nextPStart = P1CT;
  while (Q1.length > 0){
  	var BT = parseInt(Q1.dequeue());
  	var CT = nextPStart + BT;
    var TAT = CT - AT;
    var WT = TAT - BT;
    totWT = totWT + WT;
    totTAT = totTAT + TAT;
    nextPStart = CT;
  }
  var avgWT = totWT/i;
  var n = avgWT.toFixed(2);
  document.getElementById("output2").innerHTML = "Total average wait time = " + n;
  var avgTAT = totTAT/i;
  var z = avgTAT.toFixed(2);
  document.getElementById("output3").innerHTML = "Total average turn around time = " + z;
  }