In this video, you will add two more words to your Auto Editor, so it will search for a total of four words.
To do this, you will make an array.
Right now, your Auto Editor looks for the words "very" and "totally" and highlights them in red.
Your program uses the "find text" function to pass in a parameter for each search result.
But, repeating the “find text” function over and over to find different words is pretty tedious, and you might make mistakes.
Instead, use an array to store multiple search words.
An array holds multiple values.
It is similar to a variable, but it stores a group of the same type of information.
In this case, your array will be a group of words to identify and highlight in your document.
Create an array called "words."
The array starts off like a variable.
Type “var” space, “words,” space, an equal sign, and another space.
Then, type an open bracket.
The open bracket tells the computer that this is an array and will store multiple values, rather than a variable, which only stores one.
Add words to the array.
Place double quotation marks around each word and separate them with commas after the quotation marks.
For this example, use "very," "so," "totally," and "really," which are words that many people overuse in writing.
Then, add at least five more words or short phrases to the array, so it searches for writing mistakes you chose.
To see suggestions for commonly overused words you could add to your program, click the link on this page.
At the end of the list, type a closed bracket to end the array.
Check your code carefully.
Be sure you put the commas outside of the quotation mark and that you have an equals sign and both open and closed square brackets.
Add a comment to make it easy for you and others to understand the code.
Finally, check the document to make sure it contains all of the words in the array.
If it doesn’t, add a few sentences at the end of the document that contain the overused words.
In the next video, you will test your code to be sure that the values are stored correctly in the “words” array.
Now, it's your turn.
Create an array called "words" and add values to the array.
Add “very," "so," "totally," and "really” first.
Then, add at least five more values that you would like to highlight in your writing.
Add a comment to describe the array.
- Create an array called "words" and store 4 values in the array.
- Add breakpoints to your code.
- Use the Debug and "continue debugging" buttons to test that your values are correctly stored in the "words" array.
- Add a comment to describe the array.