JavaScript's split() method automatically adds the \r character at the end of the string
<p>I'm trying to create an array with the fetched data and create a new collection with it, but the resulting string has \r at the end: </p>
<pre class="brush:php;toolbar:false;">export const WordSetFn = async () =>{
let wordSet;
await fetch(wordsSet).then((resp) =>
resp.text()
).then((resp) =>{
const wordSetArray = resp.split("\n")
wordSet = new Set(wordSetArray)
})
return {wordSet};
} // word set would look like this: {"above\r",...}</pre>
<p>And the txt file I'm getting the data from is a bunch of words, each word is on the next line, like this: </p>
<pre class="brush:php;toolbar:false;">aback
abase
abate
abbey
abbot
Abhor
Abide
abled
Abode
abort
...</pre>
<p>Now why is \r added after every word? What does \r mean? </p>