I've a small code snippet in react JS wherein I'm trying to search for a value in an object 'categories' and then inserting the corresponding key-value pair in a new map sortedCategories
.
var categoriesToSort = []; //categoriesToSort has some values
var sortedCategories = new Map();
for(var j = 0 ; j < categoriesToSort.length ; j++) {
categories.forEachMap(function(key, value){
if(categoriesToSort[j] === value) {
sortedCategories.set(key, value);
}
});
}
But this is giving me the following lint error and I'm not getting any workaround.
Don't make functions within a loop