I have an array of Objects:
arrObj : [{ id: 0, text: 'At', start: '15.000' },
{ id: 1, text: 'the', start: '15.492'},
{ id: 2, text: 'left', start: '15.984'},
{ id: 3, text: 'we', start: '16.476' },
{ id: 4, text: 'can', start: '16.967'},
{ id: 5, text: 'see...', start: '17.459' },
{ id: 6, text: 'At', start: '18.166'},
{ id: 7, text: 'the', start: '18.440' }]
I have to search for an array and return the start and end word ids. For example in this case:
["At", "the"]
I have to return [(0,1),(6,7)] I am currently using a for each loop to iterate over the arrObj and see if the words match. I also tried indexOf by joining the objects texts but it returns the char index not array index.
But this does not seem efficient. How can i efficiently search for something like this?
indexOforincludesif you're targeting recent browsers.text. Is that what you're trying to do?