0
我得到這個代碼:比較兩個數組和通用對象添加到新陣列
var counter = 0,
randoms = [],
randoms1 = [],
n;
for (n = 0; n < 5; n++) {
randoms.push(Math.floor(Math.random() * 49 + 1));
randoms1.push(Math.floor(Math.random() * 49 + 1));
}
有了這2個陣列我怎麼能檢查是否有在他們一個共同的號碼,這個號碼將它添加到一個新的陣列?
首先簡單的方法:對於'randoms'每個元素,遍歷' randoms1'並比較這些值。 – 2014-09-24 15:42:19
重複的http://stackoverflow.com/questions/1885557/simplest-code-for-array-intersection-in-javascript/1885569#1885569 – Rhumborl 2014-09-24 15:43:59
@Rhumborl即時通訊不是在搜索的天才,甚至不接近尋找像一個名爲像一個主題那大聲笑 – Alpha2k 2014-09-24 15:45:22