previous

page 3

next
array of words with all letters different

I hope you remembered to double-click on words4.html.

But you would have noticed that all we got was a blank screen so we can't tell if our program was successful.
To check add these lines before the last line:

for (var i=0; i<words.length; i++) {
document.write(words[i]+'<br>');
}
document.write(words.length);

The <br> html tag ensures that each word is on a new line.
It is an abbreviation for line break.

my_words4.js

The plan is to create my_words4.js which will contain just these 1,517 words in an array called my_words4. Have a look at my words4.js to get the idea of what we are aiming for.
Note my use of // to denote a comment in JavaScript.

Change the above code to produce the same words but enclosed in single quotes and with a trailing comma.

for (var i=0; i<words.length; i++) {
document.write("'"+words[i]+"',<br>");
}

Copy & paste the output into a new file, my_words4.js and edit it to make it look like this:

var my_words4=[
'ABED',
...
'ZONE'
];
previous
next