-1
压扁×2个阵列使用if statment 我有数组1和数组2 我想ARRAY3JavaScript数组与扁平化,如果statment
<script>
var array1 = [[5,10],[6,10],[7,10],[8,10],[9,10]];
var array2 = [[1,10],[2,10],[3,10],[4,10],[5,40],[6,40]];
// only the second number will add if they are different
// [5,10] + [5,40]
// [6,10] + [6,40]
// array3 = [[1,10],[2,10],[3,10],[4,10],[5,50],[6,50],[7,10],[8,10],[9,10]];
</script>
步骤1:使用一个更好的结构(例如,地图)。第2步:现在是微不足道的 –
[JavaScript数组差异]的可能重复(http://stackoverflow.com/questions/1187518/javascript-array-difference) –
努力的成果在哪里?你甚至试图自己解决这个问题吗? – Brett