Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
175
rated 0 times [  181] [ 6]  / answers: 1 / hits: 17201  / 6 Years ago, sat, august 25, 2018, 12:00:00

I am new to JavaScript.



for learning purpose, I am trying to create a simple word typing game.



I am just stuck on the first step that is to make an array.



So How do I convert a wordlist into an array?



var words = [greet
campaign
coffee
care
revise
ridge
pilot
full
prison
wrestle
account
dictionary
start
giant
fast
monarch
patrol
bear
motif
detective
trouser
title
act
speaker
pursuit
penny
appear
ballet
agreement
welcome
similar
sensation
strong
fog
limited
implicit
nursery
neighborhood
infinite
refund
double
achievement
ample
socialist
intensify
nomination
visit
drag
retiree
mislead
situation
credit
oil
clarify
conscience
war
sow
suitcase
fixture
worth
fuss
remain
moment
frighten
spider
breathe
install
interactive
allow
deadly
cabin
restless
service
rise
integrity
artist
short circuit
perception
listen
arrangement
patience
creep
landscape
stain
citizen
microphone
nose
bullet
view
category
reign
horizon
news
social
reliable
passion
stroll
constitutional
adult
city];

More From » arrays

 Answers
12

Welcome to Stack Overflow.



Here is a way to do what you want:



var words = greet campaign coffee care revise ridge pilot full prison wrestle account dictionary start giant fast monarch patrol bear motif detective trouser title act speaker pursuit penny appear ballet agreement welcome similar sensation strong fog limited implicit nursery neighborhood infinite refund double achievement ample socialist intensify nomination visit drag retiree mislead situation credit oil clarify conscience war sow suitcase fixture worth fuss remain moment frighten spider breathe install interactive allow deadly cabin restless service rise integrity artist short circuit perception listen arrangement patience creep landscape stain citizen microphone nose bullet view category reign horizon news social reliable passion stroll constitutional adult city.split(/s+/)


This saves you the editing headache of having to put quotes and commas everywhere


[#53653] Tuesday, August 21, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brandensebastiand

Total Points: 323
Total Questions: 115
Total Answers: 106

Location: China
Member since Mon, Aug 22, 2022
2 Years ago
;