Given a JS as follows:
for (c in chars) {
for (i in data) {
if (data[i].item === chars[c]) {
// do my stuff;
}
else { /* do something else */}
}
}
and data such:
var chars = [ 'A', 'B', 'C', 'A', 'C' ];
var data = [
{'item':'A', 'rank': '1'},
{'item':'B', 'rank': '2'},
{'item':'C', 'rank': '3'}
// no duplicate
];
Is there a simpler syntax to express that rather than nested for
loops and inner conditions?
I try to match two datasets, more precisely to use chars
's keys to iterate data
and find values.