I have run this code elsewhere and it works (VSCode, Repl). It seems like the LeetCode IDE will not allow for .reduce.
Are there any documented issues with reduce or other higher order functions?
var addTwoNumbers = function(l1, l2) {
return Number(l2.reduce((a, c) => `${a}${c}`)) + Number(l1.reduce((a, c) => `${a}${c}`));
};
console.log(addTwoNumbers([1,2,3], [3,2,1]))Any help would be appreciated!
Resulting error:
Line 14 in solution.js
return Number(l2.reduce((a, c) => ${a}${c})) + Number(l1.reduce((a, c) => ${a}${c}));
TypeError: l2.reduce is not a function
Line 14: Char 20 in solution.js (addTwoNumbers)
Line 28: Char 19 in solution.js (Object.<anonymous>)
Line 16: Char 8 in runner.js (Object.runner)
Line 17: Char 26 in solution.js (Object.<anonymous>)
Line 1200: Char 30 in loader.js (Module._compile)
Line 1220: Char 10 in loader.js (Object.Module._extensions..js)
Line 1049: Char 32 in loader.js (Module.load)
Line 937: Char 14 in loader.js (Function.Module._load)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
Line 17: Char 47 in run_main_module.js
```