<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
class linkedList{
constructor(value){
this.head={
value:value,
next:null
}
this.tail=this.head
}
append(value){
const newNode={
value:value,
next:null
}
this.tail.next=newNode
this.tail=newNode
}
preappend(value){
const newNode={
value:value,
next:null
}
newNode.next=thi.head
this.head=newNode
}
insert(index,value){
const newNode={
value:value,
next:null
}
let current=this.head
for(let i=0;i<index-1;i++){
current=current.next
}
const holder=current.next
current.next=newNode
newNode.next=holder
}
}
</script>
</body>
</html>