I want to instantiate a object with its key being a variable. Something along the lines of this:
var deleteDuplicates = function(head) {
let dict = {
`${head.val}`: 1
}
}
Is something like this possible besides having another line write to it:
let dict = {}
if (head) dict[head.val] = 1
The syntax for throwing a variable in as a key is:
Source: ES6