how to set variable key in js code example
Example: javascript set object key as variable
let variableKey = "exampleKey"
let variableValue = "exampleValue"
//Add brackets around variableKey
let data = {
[variableKey] : variableValue
}
console.log(data)
//Return {"exampleKey": "exampleValue"}