I keep getting an "Unexpected token" syntax error when trying to run this code:
var newArr = arr.map(function (val, index) {
return { 'sometext' + [val.count]: val.size }
})
I have tried every different combo I can think of, but there seems to be no way to concatenate the first part of this ('sometext' + value)
I have tried two strings ('sometext' + 'someothertext') and get the same error
I have tried different notations like ${sometext } ${value}
but also no luck
If I do the following, it compiles and runs fine:
var newArr = arr.map(function (val, index) {
return { [val.count]: val.size }
})
But this is obviously not what I want since I have not prepended my value with the text I want.
I am sure there is something ridiculously simple I am missing here, but I can't see it.