class Node {
constructor(element){
this.element = element;
this.next = null;
}
}
class LinkedList {
constructor(){
this.head = null;
this.size = 0;
}
add(element){
var node = new Node(element);
var current;
if(this.head == null) this.head = node;
else {
current = this.head;
while(current.next){
current = current.next
}
current.next = node;
}
this.size++;
}
loopAndFindElement(element){
var count = 0;
var current = this.head;
while(current !== null) {
if(current.element === element){
return count;
}
count++;
current = current.next
}
return "Element not found || -1";
}
}