diff --git a/curriculum/challenges/english/blocks/data-structures/587d825a367417b2b2512c87.md b/curriculum/challenges/english/blocks/data-structures/587d825a367417b2b2512c87.md index c08c9b77154..5131d76bd43 100644 --- a/curriculum/challenges/english/blocks/data-structures/587d825a367417b2b2512c87.md +++ b/curriculum/challenges/english/blocks/data-structures/587d825a367417b2b2512c87.md @@ -94,7 +94,13 @@ assert( test.add(5); test.add(6); test.add(723); - return test.print().join('') == '56723'; + var result = []; + var curr = test.head; + while (curr) { + result.push(curr.data); + curr = curr.next; + } + return result.join('') == '56723'; })() ); ``` @@ -111,7 +117,13 @@ assert( test.add(50); test.add(68); test.add(73); - return test.printReverse().join('') == '736850'; + var result = []; + var curr = test.tail; + while (curr) { + result.push(curr.data); + curr = curr.prev; + } + return result.join('') == '736850'; })() ); ``` @@ -129,7 +141,13 @@ assert( test.add(35); test.add(60); test.remove(25); - return test.print().join('') == '3560'; + var result = []; + var curr = test.head; + while (curr) { + result.push(curr.data); + curr = curr.next; + } + return result.join('') == '3560'; })() ); ``` @@ -147,48 +165,17 @@ assert( test.add(35); test.add(60); test.remove(60); - return test.print().join('') == '2535'; + var result = []; + var curr = test.head; + while (curr) { + result.push(curr.data); + curr = curr.next; + } + return result.join('') == '2535'; })() ); ``` -# --before-each-- - -```js -DoublyLinkedList.prototype = Object.assign( - DoublyLinkedList.prototype, - { - - print() { - if (this.head == null) { - return null; - } else { - var result = new Array(); - var node = this.head; - while (node.next != null) { - result.push(node.data); - node = node.next; - }; - result.push(node.data); - return result; - }; - }, - printReverse() { - if (this.tail == null) { - return null; - } else { - var result = new Array(); - var node = this.tail; - while (node.prev != null) { - result.push(node.data); - node = node.prev; - }; - result.push(node.data); - return result; - }; - } -}); -``` # --seed--