Is there any way to use Map.get() with an array of arrays (specifically in d3.js)?
Here's what I have: (1) Map – containing data in over 100 key-value pairs (2) Array of arrays – listing the keys of the data I want to pull from the Map for populating a table (only a subset of the 100+ values)
Here's what I need to create: (1) A new array of arrays – this new array should take each item from the first array in turn, look up the key in the Map and return the value.
I can get Map.get() to work just fine over a single array, but only if I specify the index of the nested array, like this:
var myMap;
var dataArray = [key_1, key_2, key_3, key_4, key_5, key_6]
var newArray = dataArray[0].map(function(d) {
return myMap.get(d);
});
But when my original array is an array of arrays, I can't figure out how to do it:
var myMap;
var dataArray = [
[key_1, key_2, key_3],
[key_4, key_5, key_6],
[key_7, key_8, key_9]
]
var newArray = ???
Any suggestions?