0

onLoadLang is a variable declared as "en_us" earlier in the code.

when I try to push using the following:

UdfHeaderFields["translations"].push({ onLoadLang: [{ "H1": "English" }, { "H2": "English" }, { "H3": "English" }, { "H4": "English" }, { "H5": "English" }] });

The onLoadLang portion gets pushed as "onLoadLang" and not "en_us"

enter image description here

Here is what it looks like after the step over.

enter image description here

I have tried surrounding it with various char types to no avail.

iviouse
  • 449
  • 6
  • 9

1 Answers1

1

You should put square brackets around the variable name if you don't want it to be treated as a literal. Consider this working code example:

let x = "en_us"
let y = []
y.push( { x: "the key is x" } )
y.push( { [x]: "the key is en_us" } )
console.log(y)
Always Learning
  • 5,510
  • 2
  • 17
  • 34