function largestOfFour(arr) { var biao = []; for (i = 0 ;i < arr.length;i++){ var count = 0; var sum = 0; document.write('-----<br>'); for(j = 0;j < arr[i].length;j++){ sum += arr[i][j]; count++; //document.writeln(arr[i][j]); if(count == 4){ biao.push(sum); h = 0; h++; document.writeln(h+':'+biao); } } } return biao; } largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);