Information: I am currently organizing an array of names into two separate arrays - one for names starting with A-M and the other for names starting with N-Z. My goal is to have each entry represented as an object with the name as the property and an empty string as the value, structured like this --> {'Name' : ' '} . However, all entries are coming out as follows --> {val: ' '}
Here is how I am pushing entries --> arrAM.push({val: ' '});
Query: How can I alter the above method to include the actual Name instead of just "val"? Thank you in advance for any assistance!
var separate = function(array){
var arrAM = [];
var arrNZ = [];
_.each(array, function(val){
if (/^[a-m]/i.test(val)){
arrAM.push({val: ''});
}
else{
arrNZ.push({val: ''})
}
})
return arrAM;
}