function addTwoNumbers (l1, l2) { var sum1 = 0; var sum2 = 0; var sum3 = 0; var arr = [] var l11 = l1.reverse() var l22 = l2.reverse() for(var i =0 ; i < l11.length ; i++) { var num1 = l11[i]*Math.pow(10,i) sum1 += num1; } for(var j = 0; j < l22.length ; j++) { var num2 = l22[j]*Math.pow(10,j) sum2 += num2; } sum3 = sum1 + sum2 return sum3.toString().split("").reverse().map(Number) } var l1 = [1,2,3] var l2 = [1,2,3] addTwoNumbers(l1,l2) console.log(addTwoNumbers(l1,l2))