Hi
I need some help figuring out the remove function from my list.
It is not working properly any help would appreciated.
Here the code:
function List() { this.head = {data:null, next:null};
};
List.prototype.add = function(data) {
var node = {
data: data,
next: this.head
};
this.head = node;
};
List.prototype.remove = function() {
this.head = this.head.next;
this.head.next = this.head.data;
return this.head.data;
};