SOURCE

// Definition for singly-linked list.

class ListNode {
    val: number
    next: ListNode | null
    constructor(val?: number, next?: ListNode | null) {
        this.val = (val===undefined ? 0 : val)
        this.next = (next===undefined ? null : next)
    }
}

function addTwoNumbers(l1: ListNode | null, l2: ListNode | null): ListNode | null {
    // for (num of l1){
    // }
    console.log(l1)
    console.log(l2)
    
    return l1;
};

const one = new ListNode(2);
one.next = new ListNode(4);
one.next.next = new ListNode(3);

const two = new ListNode(5);
two.next = new ListNode(6);
two.next.next = new ListNode(4);

addTwoNumbers(one,two);
console 命令行工具 X clear

                    
>
console