/* * 输入两个非负整数,以数组形式反向排序显示,相加并返回新的数组 * Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) * Output: 7 -> 0 -> 8 */ var addtwonumbers = function( list1, list2 ){ var resultNumberList = [] newList1 = list1.reverse().join('') newList2 = list2.reverse().join('') addNumber = parseInt(newList1)+ parseInt(newList2) addString = addNumber.toString() for( var i = 0; i < addString.length; i ++ ){ resultNumberList.push( parseInt(addString[i]) ) } return resultNumberList.reverse()}