-1

My json code:

var jsontest = {
    "testlang": "no no testlang dziala lol"
}

i want get "testlang" by variable, eg:

var variabletest = "testlang";
jsontest.variabletest

can anyone help plz?

1 Answers1

0

In this case the below would work

const jsontest = {
    "testlang": "no no testlang dziala lol"
}
const variabletest = "testlang";
console.log(jsontest[variabletest])
omeanwell
  • 1,847
  • 1
  • 10
  • 16