I have a video timeline containing several videos and I’m trying to create popups to go along with each video
I am trying to get the popups to appear when the video plays and if there is more than one object in the corresponding array, go through them and then carry on with the video
I’ve tried getting the objects entries and looping over them but it gives me both as opposed to just one
let popups = {
0: [{
type: 'alert',
text: 'Alert text',
},
{
type: 'warning',
text: 'Warning text',
},
],
1: [{
type: 'caution',
text: 'Caution text',
}, ],
};
3
Answers
The way I figured this out was using the Object.keys() and Object.values() method and nesting forEach loops inside forEach loops.
If I understand your question, you just need a foreach inside a foreach:
The popups is an object so you first need to iterate it, there is the Object.entries() method in js.