// 查找数组中某个元素所有出现的索引
// needle 查找元素 haystack 目标数组
function find(needle, haystack) {
var results = [];
var idx = haystack.indexOf(needle);
while (idx != -1) {
results.push(idx);
idx = haystack.indexOf(needle, idx + 1);
}
return results;
}
// var scores = [10, 20, 30, 10, 40, 20];
// console.log(find(10,scores));