I'm having a problem when i'm trying to access the text that i have stored in a string array. I know, the problem seems so easy, but I just can't figure out where i'm going wrong...
So when i'm console logging the contents of the array to the browser, I can see that i get values as follows:
console.log(myStringArray)
output:
10[...]
0: "a lot of text here"
1: "also here"
2: "and here... etc"
...
But when i'm trying to access the values like:
myStringArray[0];
The result i'm getting is a one slotted array with nothing in it like:
(1)[...]
0: ""
length: 1
>_proto__: Array[]
Trying to convert the result into strings etc didnt work so well either. Could someone help me access these values, thanks!
Edit: The text that i'm getting is articles from wiki:s API.
function getMoreText(){
for(let j = 0; j < titlesInSearch.length; j++){
textContent[j] = [''];
textUrl = 'https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=' + titlesInSearch[j];
$.getJSON({
url: textUrl,
dataType: "jsonp",
success: function(data, status, xhr) {
var page = data.query.pages;
var pageId = Object.keys(page)[0];
if(page[pageId].title == titlesInSearch[j]){
textContent[j] = page[pageId].extract;
}
}
})
}
}
and when i'm console logging the values, when i'm going to update the HTML code, the result are as I explained above:
function updateGUI(){
//resetting when getting new articles
document.getElementById("artikel").innerHTML = '';
//getting the result
console.log(textContent);
//not getting anything
console.log(textContent[0]);
for(let b = 0; b < titlesInSearch.length; b++)
{
console.log(textContent[b]);
if(summary[b].includes("may refer to:")){
console.log("filtered: 'may refer to'") //do nothing
}
else if(summary[b] != ''){
document.getElementById("artikel").innerHTML += ('<div>' + textContent[b] +'</div>');
}
}
}