我[2016,2017,2018,2019]刪除範圍
的陣列我有一個範圍fromValue 2017 toValue 2017
因此所得陣列應採用[2017]由於我需要刪除fromValue和toValue之間的任何範圍。
我已經寫了下面的代碼這是隻有消除2016和2018,但不是2019年
哪些錯誤我在做什麼,有沒有什麼辦法尤爲明顯要做到這一點?
gNodeIDs.forEach(function (item) {
alert("Before if" + item);
if (item >= fromValue) {
if (item <= toValue) {
}
else
{
alert("removing" + item);
var index = test.indexOf(item);
if (index >= 0) {
test.splice(index, 1);
}
}
}
else {
alert("removing" + item);
var index = test.indexOf(item);
if (index >= 0) {
test.splice(index, 1);
}
}
});
怎麼樣?使用過濾器? – SmartestVEGA