-2

i'm writing an app that retrieve data from a json array. This array have results in different languages and i need to set a variable to select which language to show.

now i have:

const descArt = document.getElementById('descArtist').innerText = data.artists[0].strBiographyEN

that retrieve the description in EN (english)

so i've created a variable:

const arrayElem = 'strBiography' + languageCode;

but i do not know how can i set this variable inside my item call.

1 Answers1

0

If your Elemnt is a JSON-Object:

const arrayElem = 'strBiography' + languageCode;
const descArt = document.getElementById('descArtist').innerText = data.artists[0][arrayElem];