We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6a95577 commit e88a1f6Copy full SHA for e88a1f6
linked-list-double.js
@@ -86,6 +86,20 @@ class DoublyLinkedList {
86
console.log(list);
87
}
88
89
+
90
+ printReverse() {
91
+ if (this.isEmpty()) {
92
+ console.log("List is empty");
93
+ } else {
94
+ let curr = this.tail;
95
+ let list = "";
96
+ while (curr) {
97
+ list += `${curr.value}<->`;
98
+ curr = curr.prev;
99
+ }
100
+ console.log(list);
101
102
103
104
105
const list = new DoublyLinkedList();
@@ -94,6 +108,7 @@ list.append(2);
108
list.append(3);
109
list.prepend(0);
110
list.print();
111
+list.printReverse();
112
list.removeFromEnd();
113
114
list.removeFromFront();
0 commit comments