Skip to content

Commit c828f9b

Browse files
committed
done with basic linked-list
1 parent 0d671a7 commit c828f9b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// this file for linked-list implementation
2+
3+
class LinkedNode {
4+
constructor(data, next = null, head) {
5+
this.data =data;
6+
this.next = next;
7+
this.head = head;
8+
}
9+
allNextNode =()=> {
10+
let nextNode = this;
11+
do {
12+
console.log(nextNode.data);
13+
nextNode = nextNode.next;
14+
} while (nextNode.next);
15+
console.log(nextNode.data);
16+
}
17+
}
18+
19+
// testing ;
20+
function testLinkedList() {
21+
const three = new LinkedNode(4,false ,false);
22+
const two = new LinkedNode(3,three ,false);
23+
const one = new LinkedNode(2,two ,false);
24+
const head = new LinkedNode(1,one,true);
25+
head.allNextNode();
26+
}
27+
testLinkedList();

0 commit comments

Comments
 (0)