freeCodeCamp/Data Structures/linkedList.js

16 lines
405 B
JavaScript
Raw Permalink Normal View History

// 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;