Add playground.

This commit is contained in:
Oleksii Trekhleb 2018-04-09 19:43:09 +03:00
parent 0052337df9
commit 840635e613

View File

@ -133,15 +133,19 @@ export default class LinkedList {
return deletedHead;
}
toString(callback) {
const nodeStrings = [];
toArray() {
const nodes = [];
let currentNode = this.head;
while (currentNode) {
nodeStrings.push(currentNode.toString(callback));
nodes.push(currentNode);
currentNode = currentNode.next;
}
return nodeStrings.toString();
return nodes;
}
toString(callback) {
return this.toArray().map(node => node.toString(callback)).toString();
}
}