From 50241c7a38711536f8cfcfbbcde667a2a55a3bd1 Mon Sep 17 00:00:00 2001 From: CheezItMan Date: Thu, 8 Aug 2019 15:38:39 -0700 Subject: [PATCH] Node class --- print_list.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 print_list.js 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