I try to fetch a text from a local txt file and create an array consisted of all words from the file. Just like ['this', 'is', 'a', 'sample', 'text'...]. The problem is that I cannot do anything with the resulting array. I cannot loop it with forEach or even access any item. I think I should transform the array is some way but have no idea how. This is the screenshot of the array in console Probably the question is quite silly, but I am very beginner at JS. Thanks.
const arr = []
fetch('sample.txt')
.then(response => response.text())
.then(data => data.split(' '))
.then(result => arr.push(...result))
console.log(arr)