let list = {
value: 1,
next: {
value: 2,
next: {
value: 3,
next: {
value: 4,
next: null
}
}
}
};
function reverseNext(list) {
for(elem in list) {
if(typeof list[elem] == 'object') {
reverseNext(list[elem])
console.log(list.value)
}
}
}
reverseNext(list)
if(typeof list[elem] == 'object') {
console.log(list.value);
reverseNext(list[elem])
}
if(typeof list[elem] == 'object') {
reverseNext(list[elem])
} else {
console.log(list.value)
}