console.log: A0004A0003A0001A0005A0004A0002A0001
но я ожидаю, что console.log будет: A0004, A0001
Следовательно, чего не хватает в этой функции цикла?
var imagedata = [{
id: "A0007",
class: "chair house grass"
},
{
id: "A0006",
class: "car house tree flower grass"
},
{
id: "A0005",
class: "car house tree flower"
},
{
id: "A0004",
class: "car tree"
},
{
id: "A0003",
class: "chair tree flower grass"
},
{
id: "A0002",
class: "chair house flower"
},
{
id: "A0001",
class: "car flower"
},
{
id: "A0000",
class: "chair car house tree flower grass"
}
];
function myFunction() {
var o2y = ["1", "all", "0", "1", "all", "0"];
var o3x = ["chair", "car", "house", "tree", "flower", "grass"];
var m0x = "";
var m1x = "";
for (i = 0; i < o3x.length; i++) {
m0x = o3x[i];
for (j = 0; j < imagedata.length; j++) {
if (o2y[i] == "0") {
if (imagedata[j].class.search(m0x) < 0) {
m1x += imagedata[j].id;
console.log(m1x);
}
}
};
};
}
myFunction();