JSFiddle - React, Tailwind, and code Playground
JavaScript
var someList = {
value: 1,
next: {
value: 2,
next: {
value: 3,
next: {
value: 4,
next: null
}
}
}
};
function reversePrint(linkedList) {
Object.keys(linkedList).reduce((myarray, key) => {
var one = reversePrint(linkedList[key]);
var two = linkedList[key];
if (typeof linkedList[key] == "object")
myarray.push(one);
myarray.push(two);
console.log(myarray);
}, []);
}
reversePrint(someList);