vendredi 10 avril 2020

random item display in javascript

I am experimenting a little bit during this quarantine and I am working on a personal project but I am stuck. Basically I want to parse subtitles from srt files (which I already did by following this Parse a SRT file with jQuery Javascript). But now I do want to display just one subtitle at the time (only text), i have tried with:

    document.body.innerHTML += subtitles[cont].text;
    var randomItem = t[Math.floor(Math.random()*t.length)];
    document.body.innerHTML = randomItem; 

but the problem with it is that I get only one letter at the time, good thing is it random but I do want the whole subtitle. If I console.log subtitles[cont].text I get this

And I can see they are separated. But I can't understand how to get only one of the two.




Aucun commentaire:

Enregistrer un commentaire