Alex
Alex2y ago

✅ – Alex. – 10-04 Oct 30

Hi i have this code :
fetch("./Data/normal.txt")
.then((r) => r.text())
.then((text) => {
console.log(
'["' +
text.replaceAll(" = ", '","').replaceAll("\n", '"],\n["') +
'"]'
)
})
fetch("./Data/normal.txt")
.then((r) => r.text())
.then((text) => {
console.log(
'["' +
text.replaceAll(" = ", '","').replaceAll("\n", '"],\n["') +
'"]'
)
})
What this code does is: it takes the text from text file then it convert them to array type but the array is string and i want it to be array what should i do?
// Data inside normal.txt
der Spiegel = the mirror
die Spinne = the spider
// Data inside normal.txt
der Spiegel = the mirror
die Spinne = the spider
2 Replies
lebouwski
lebouwski2y ago
text.split(/\r?\n/).map(line => line.split(" = "))
reactibot
reactibot2y ago
This question has an answer! Thank you for helping 😄 If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1036219106740940810 This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1036219106740940810