I've got an array of channels that I want to transform into a single object (channelSettings) with a true / false property for each channel.
I've got it working using the below code but it seems verbose. Is there are way to do it without the temp var? If I can get ride of that, then I could get ride of the self executing function as well.
var channels = [TV, Billboard, Spot TV];
var channelSettings = function() {
var temp = {};
channels.map(function(itm, i, a) {
var channel = itm.toLowerCase().replace( , );
temp[channel] = false;
});
return temp;
}();
I guess I'm trying to get the map function to return an object with properties instead of an array. Is this possible? Is it mis-guided? Suggestions?
This is what I'm hoping it looks like in the end:
var channels = [TV, Billboard, Spot TV];
var channelSettings = channels.map(function(itm, i, a) {
var channel = itm.toLowerCase().replace( , );
return ????;
});