// цикл
function printList(list) {
for (var a = list; a; a = a.next) {
console.log(a.value)
}
}
// рекурсия
function printList(list) {
if (list) {
console.log(list.value);
printList(list.next);
}
}
printList(list);
function printReverseList(list) {
var arr = [];
for (var a = list; a; a = a.next) {
arr.unshift(a.value);
}
for (let i = 0; i < arr.length; i++) {
console.log(arr[i])
}
}
function printReverseList(list) {
if (list) {
printReverseList(list.next);
console.log(list.value);
}
}
printReverseList(list)