Skip to content

Commit 840635e

Browse files
committed
Add playground.
1 parent 0052337 commit 840635e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: src/data-structures/linked-list/LinkedList.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,19 @@ export default class LinkedList {
133133
return deletedHead;
134134
}
135135

136-
toString(callback) {
137-
const nodeStrings = [];
136+
toArray() {
137+
const nodes = [];
138138

139139
let currentNode = this.head;
140140
while (currentNode) {
141-
nodeStrings.push(currentNode.toString(callback));
141+
nodes.push(currentNode);
142142
currentNode = currentNode.next;
143143
}
144144

145-
return nodeStrings.toString();
145+
return nodes;
146+
}
147+
148+
toString(callback) {
149+
return this.toArray().map(node => node.toString(callback)).toString();
146150
}
147151
}

0 commit comments

Comments
 (0)