From e33373fa001604486ec351a82e2e4d5f472d8fb3 Mon Sep 17 00:00:00 2001 From: Manish Date: Thu, 24 Aug 2023 12:49:30 +1000 Subject: [PATCH] Data Structures: Work with Nodes in a Linked List --- Data Structures/linkedList.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Data Structures/linkedList.js diff --git a/Data Structures/linkedList.js b/Data Structures/linkedList.js new file mode 100644 index 0000000..7862cf1 --- /dev/null +++ b/Data Structures/linkedList.js @@ -0,0 +1,15 @@ +// https://www.freecodecamp.org/learn/coding-interview-prep/data-structures/work-with-nodes-in-a-linked-list + +var Node = function (element) { + this.element = element; + this.next = null; +}; +var Kitten = new Node("Kitten"); +var Puppy = new Node("Puppy"); + +Kitten.next = Puppy; +// Only change code below this line +const Cat = new Node("Cat"); +Puppy.next = Cat; +const Dog = new Node("Dog"); +Cat.next = Dog;