I do not understand the reason why this is not working.
function LinkedList() {
var length = 0;
var head = null;
var Node = function(element){
this.element = element;
this.next = null;
};
this.head = function(){
return head;
};
this.size = function(){
return length;
};
this.add = function(element){
let node = new Node (element);//Creación del nuevo nodo
if(this.head===null){
head = node
}else{
let currentNode = head;
while(this.next){
currentNode=this.next;
}
this.next=node;
}
length++
};
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Challenge: Create a Linked List Class
Link to the challenge: