JSFiddle - React, Tailwind, and code Playground
by hescano
JavaScript
function Node(data) {
this.data = data;
this.next = null;
}
function push(head, data) {
if (head === null) {
head = new Node(data);
} else {
var tmp = head;
head = new Node(data);
head.next = tmp;
}
return head;
}
function buildOneTwoThree() {
var chained = null;
chained = push(chained, 3);
chained = push(chained, 2);
chained = push(chained, 1);
return chained;
}
var x = push(new Node(1), 2);
console.log(x.data)