JSFiddle - React, Tailwind, and code Playground
by MuLtDirectX
JavaScript
class LinkedList{
constructor(){
}
add(newValue){
this.data = {
value: newValue,
children: this.data
}
}
/*
first(){
var i
while (this.data.children) {
i = this.data.children
this.data.children = this.data.children.children
}
return i.value
}
last(){
return this.data.value
}*/
size(){
var newObj = []
for (var key in this.data) {
newObj[key] = this.data[key];
}
var i = 1
while(newObj.children){
newObj.children = newObj.children.children
i++
}
return i
}
get(item){
var len = this.size()
while(this.data.children){
this.data.children = this.data.children.children
console.log('ololo')
}
}
}
var links = new LinkedList()
links.add('1st element')
links.add(2)
links.add('3')
links.add(8)
links.add('9')
links.add(10)
console.log(links.size())