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:
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",...}
And the txt file I'm getting the data from is a bunch of words, each word is on the next line, like this:
aback abase abate abbey abbot Abhor Abide abled Abode abort ...
Now why is \r added after every word? What does \r mean?
\r
is a carriage return character,\n
is a line feed character,\r\n
is a carriage return character plus a line feed character.