How can I an array of functions to an object with keys as functions' name and values as functions' return values. An example would be:
var a=x=>"M",b=_=>"e",c=_=>"r",d=_=>"y",e=_=>"C",
f=_=>"h",g=_=>"i",h=_=>"s",i=_=>"t",j=_=>"m",
k=_=>"a",l=_=>" ",m=_=>"!",
funcs = [a,b,c,d,e,f,g,h,i,j,k,l,m]
// do some magic with funcs to receive myDict
var myDict = {'a':'M', 'b':'e', 'c':'r', 'd':'y', ...}
I tried something like this but it didn't work.
var dict = funcs.reduce(function (acc, func) {
acc[func.name] = func();
return acc;
}, {});
How can I fix this to achieve the wanted result? Is there a better without using reduce?