linked list notes

by Juan Alban Franco

HTML

<html>
<body>
 <script>
 function linkedlist (){
 this.head = null;
 this.tail null;
 this.length = 0;
 }
 
 function Node () {
 	this.next = null;
  this.previous = null;
  this.content = null;
  }

linkedlist.prototype.add(data) {
 var node = new Node(); node.contet = data;
	if(this.length > 0)
  {
  	this.tail.next = node
  }
  
  this.tail.next = node;
  node.previous = this.tail;
  this.length ++;
  this.tail = node;
  
  }

linkedlist.prototype.print = function()
{
	if(this.head == null)
  {
  	return "Empty list";
  }
  var s = " ";
  var current = this.head;
  while (current)
  {
  	s += current.content + " ";
    current = current.next;
  }
  return s;
}


var aList = new linkedlist;
function add(){
var c = document.getElementById("v").value;
aList.add(c);
var string = aList.print();
document.getElementById("output").innerHTML = string;
}

 
 
 
 
 
 </script>


</body>
<input type = "textbox" id = "v" value = "Node 1"/>
<input type = "button"  id = "add" value = "Add Node" onlick = "addnode()"/>
<br>
<br>
<br>
<div id="output">

</div>
</html>