编辑代码

const n1 = {
    value: 1,
    next: {
        value: 2,
        next: {
            value: 3,
            next: {
                value: 4,
                next: {
                    value: 5,
                    next: null
                }
            }
        }
    }
}

function deleteNode(value) {
    let head = n1;
    while(head !== null) {
        if(head.value === value) {
            head.value = head.next.value;
            head.next = head.next.next;
        }
        head = head.next;
    }
}
deleteNode(3)
console.log(n1)