const utterances = ['utt01', 'utt02', 'utt03']
const analysis = ['try+ing', 'climb+ing', 'swimm+ing']
const translation = ['trying', 'climbing', 'swimming']
let utteranceIndex = 0;
loadUtterance(utterances[utteranceIndex]);
function loadUtterance(utterance) {
audio.src = `audio/${utterance}.mp3`;
subtitle.innerText = utterance;
translation.innerText = translation;
}
This is meant to be an exercise for studying a foreign text. I want to
- load and play the first utterance in the array;
- display the transcription (subtitle) of the utterance;
- Display the English translation. Then play the next utterance.
I have added the "analysis" array to help visualize what I am trying to do. Eventually I'd like to display the translation (and the analysis) only after an eventListener (the student's request with a click).
Problem: the translation items do not load with this script. I am a long retired linguist looking for some guidance. Thank you.
Based on your description, there might be different reasons:
if you intend to display the whole array of translation/analysis, the problem is translation.innerText is actually operating the array you declared above instead of the html element, so if your html element that you want to show translation in's id is "translation", simply change your function to below should fix your problem:
Or if you want to display only the translation/analysis with the same utteranceIndex, then the function in your code seems in lack of couple input parameters (translation, analysis), Try the code below: