just started to dabble with Javascript so I'm sorry if this is a basic question. I have an array of keys:
keys = ['fruits','vegetables','fats','meats']
I want to dynamically create a Map for each of these elements in the array (the length of this array may change). I'm trying to do something like this:
for (var i=0; i<keys.length; i++) {
map_name = keys[i];
var map_name = new Map();
map_name.set('foo','bar');
}
console.log(fruits)
Output: fruits is not defined
I've tried searching for some kind of syntax to be able to dynamically create this while also being able to access the Maps that are created globally, but I can't seem to find a solution.
Thank you!