I am not enough good in JS and can make mistakes but where is the problem in my code?
Code:
var addTwoNumbers = function(l1, l2) {
let list = []
for(let i = 0; i < ((l1.length >= l2.length) ? l1 : l2).length; i++){
if(l1[i] == undefined) l1[i] = 0
if(l2[i] == undefined) l2[i] = 0
var sum = l1[i] + l2[i]
if((sum - 10) >= 0){
if(l1[i+1] == undefined) l1[i+1] = 0
l1[i+1] += 1
sum -= 10
}
list.push(sum)
}
return list
};Runtime Error:
Line 32 in solution.js
throw new TypeError(serialize(ret) + " is not valid value for the expected return type ListNode");
^
TypeError: [] is not valid value for the expected return type ListNode
Line 32: Char 20 in solution.js (Object.)
Line 16: Char 8 in runner.js (Object.runner)
Line 16: Char 26 in solution.js (Object.)
Line 1251: Char 30 in loader.js (Module._compile)
Line 1272: Char 10 in loader.js (Object.Module._extensions..js)
Line 1100: Char 32 in loader.js (Module.load)
Line 962: Char 14 in loader.js (Function.Module._load)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Line 17: Char 47 in run_main_module.js