|
Hello, I am attempting to create a spell checker using javascript. I am new but I have experience.
I am not using a dictionary, instead I want to use an array to hold 6 or 7 words that are spelled correctly.
The user will enter one of the words in a text box and hit a button (labeled spell check of course).
I am assuming I am going to want to use an on-click event for the button that will compare the word submitted in the textbox to one of the 6 or 7 words in the array.
I have the html and css done. I have also created the array.
I am not sure how I would compare the string that is inputted by the user to my wordlist array. I need help please.
This should (in theory) create a spell checker that will check the words in my array.
var wordlist = new Array(6);
wordlist[0] = "dog";
wordlist[1] = "potato";
wordlist[2] = "napkin";
wordlist[3] = "knife";
wordlist[4] = "pumpkin";
wordlist[5] = "probably";
wordlist[6] = "wednesday";
|
|
|
|
|
use indexOf
wordlist = ['dog', 'potato', 'napkin', 'knife', 'pumpkin', 'probably', 'wednesday']
wordlist.indexOf('dog')
0
wordlist.indexOf('potato')
1
wordlist.indexOf('potatou')
-1
|
|
|
|