JSFiddle - React, Tailwind, and code Playground

JavaScript

class LinkedList {
	constructor() {
    this.head = new Node("", null);
  }
  
  addNode(node) {
  	let curr = this.head;
  	while(curr.next) {
    	curr = curr.next;
    }
    curr.next = node;
	}
}

class Node {
	constructor(data, node) {
  	this.data = data;
    this.next = node;
  }
}

let linkedList = new LinkedList();

linkedList.addNode(new Node("1", null));
linkedList.addNode(new Node("2", null));
linkedList.addNode(new Node("3", null));

let current = linkedList.head;
while(current.next) {
	console.log(current);
 	current = current.next;
}