example1
fns = {
Month: 'months',
Day: 'days'
};
let test = "Month";
console.log(fns[test]); // successful with "months"
durationFns.toString({ months: value }); // successful
//Error1: Gets Parsing error(eslint): Unexpected token [
//Error2: ',' expected.ts(1005)"
durationFns.toString({fns[test]: value});
I basically want fns[test]
to convert to months
but above didn't work.
What should I do? Thank you for suggestions