File tree 2 files changed +5
-5
lines changed
2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -56,12 +56,12 @@ let CircularLinkedList2 = (function () {
56
56
previous ,
57
57
index = 0 ;
58
58
59
- if ( position === 0 ) { //add on first position
59
+ if ( position === 0 ) { //add on first position
60
60
61
61
node . next = current ;
62
62
63
63
//update last element
64
- while ( current . next !== head ) { //last element will be head instead of NULL
64
+ while ( current . next !== this . getHead ( ) ) { //last element will be head instead of NULL
65
65
current = current . next ;
66
66
}
67
67
@@ -101,7 +101,7 @@ let CircularLinkedList2 = (function () {
101
101
//removing first item
102
102
if ( position === 0 ) {
103
103
104
- while ( current . next !== head ) { //needs to update last element first
104
+ while ( current . next !== this . getHead ( ) ) { //needs to update last element first
105
105
current = current . next ;
106
106
}
107
107
Original file line number Diff line number Diff line change 1
1
let circularLinkedList = new CircularLinkedList2 ( ) ;
2
2
3
- /* circularLinkedList.append(15);
3
+ circularLinkedList . append ( 15 ) ;
4
4
circularLinkedList . print ( ) ;
5
5
6
6
circularLinkedList . append ( 16 ) ;
@@ -25,4 +25,4 @@ circularLinkedList.removeAt(2);
25
25
circularLinkedList . print ( ) ;
26
26
27
27
console . log ( circularLinkedList . indexOf ( 14.5 ) ) ;
28
- console.log(circularLinkedList.indexOf(16));*/
28
+ console . log ( circularLinkedList . indexOf ( 16 ) ) ;
You can’t perform that action at this time.
0 commit comments