0

So I'm trying to get data from a JSON and I declared a variable and want to use the thing from that variable to get info from the JSON I'm trying to do this but I don't know what the problem is

let e = "KA8AL9AE";
let codes = '{"T9R3P5YE": "10", "8HAW69VC": "20"}'
codes = JSON.parse(codes)
console.log(codes.e)

I've tried doing

let e = "KA8AL9AE";
let codes = '{"T9R3P5YE": "10", "8HAW69VC": "20"}'
codes = JSON.parse(codes)
console.log(`${codes. + e}`)

But it didn't work, Is there a way to do this?

DarkInk
  • 23
  • 6

1 Answers1

0

You could call the new key like: codes[e]

Rateb Habbab
  • 1,739
  • 8
  • 13