简体   繁体   中英

How can I convert a single-line array into a multi-line array?

I'm trying to make something that picks a random word out of the english dictionary as a word for the game hangman. I found a good word list: http://www.mieliestronk.com/corncob_lowercase.txt and i've managed to convert it into an array. One problem though, it's an array on a single line and it's longer than 20k characters. If i try to copy paste the array into my project, it says that it's too long. So i wanted to convert it into a multi-line array. I've seen people use regexes but everytime i try it, it doesn't work at all... So, does anyone have a solution to my problem? Note: i've just started programming, so sorry if this question is really stupid or if i didn't explain it correctly.

I would check out prettier https://prettier.io/ , or another code formatter. This will get you started in formatting your code the way you want while you are developing.

I am unsure what is the question tho

write this into the console

console.log(document.getElementsByTagName('pre')[0].textContent.split(/\s+/));

you get an array that contains the words as values

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM