Consider this JavaScript array structure:
let text = [
{
line: [{
words: [{
word: [
{ letter: 'H' },
{ letter: 'i' },
{ letter: ' ' },
],
},
{
word: [
{ letter: 'J' },
{ letter: 'i' },
{ letter: '\n' },
],
}],
}]
},
{
line: [{
words: [{
word: [
{ letter: 'H' },
{ letter: 'i' },
{ letter: ' ' },
],
},
{
word: [
{ letter: 'J' },
{ letter: 'o' },
{ letter: '\n' },
],
}],
}]
}
Is there a quick and easy way to access the nth letter in this array?
- If n=0, get 'H'
- If n=1, get 'i'
- ...
- If n=11, get 'o'
You can also check out this JSFiddle for reference: https://jsfiddle.net/Imabot/6usdej75/