Fellow programmer here, for some reason I have spent two days but I cannot do this properly so help me out. I have an object with arrays for each key like this:
var arraysObject = {
"North American": [
"CONUS",
"NAMER",
"CONUS/AK",
"US-NC",
"US-NE",
"US-NW",
"US-SC",
"US-SE"
],
"Oconus": [
"ALASKA",
"GUAM",
"HAWAII",
"POLAR",
"US-SAMOA"
],
}
I have a list of areas that have been selected, like the following
var listOfAreas = ["CONUS", "GUAM","US-SAMOA"]
I want to create the following object:
var result = [{
"North American":"CONUS",
"Oconus": "GUAM"
},
{
"North American": "",
"Oconus":"US-SAMOA"
}]
Notice how it created a new object only when that last one's key is full and fills the object if possible. in my implementation it creates an object for each individual string and assigns it to the key using then pushes it using .map This doesn't work. I want it to fill each object accordingly and create an new object only when it is necessary. Appreciate your help. Best, A dummy.
[CONUS, NAMER]? Because it seems the "unique" values should be come the keys, not the other way around.