diff --git a/print_list.js b/print_list.js new file mode 100644 index 0000000..588ce37 --- /dev/null +++ b/print_list.js @@ -0,0 +1,34 @@ + +class Node { + constructor(value, next) { + this.value = value; + this.next = next; + } + + getNext() { + return this.next; + } + + setNext(next) { + this.next = next; + } + + getValue() { + return this.value; + } + + setValue(value) { + this.value = value; + } + + printList() { + let current = this; + + while (current != null) { + console.log(current.value); + current = current.getNext(); + } + } +} + +export default Node; \ No newline at end of file