I have the following code:
headerCaptions.push(localization.SCREEN_EPISODE_INITIATION_HEADER_REQUEST1);
headerCaptions.push(localization.SCREEN_EPISODE_INITIATION_HEADER_REQUEST2);
headerCaptions.push(localization.SCREEN_EPISODE_INITIATION_HEADER_REQUEST3);
headerCaptions is an array. The localization object contains string values.
I want to generate this dynamically, i.e. map through x number of times, the number of the object parameter increasing by one with each iteration. For example to make 4 would make the final method call SCREEN_EPISODE_INITIATION_HEADER_REQUEST4 and so on.
I am happy to use vanilla js or the new ES6 syntax.
headerCaptions.push(localization['SCREEN_EPISODE_INITIATION_HEADER_REQUEST' + i];.