In this example the array is used just like a spread sheet. So imagine one.
First column = word
Second column = number of times it was present in the previous sentence
Third column = number of times it is present in the current sentence
(remember: first column has the Y-index 0)
Each word has its own row
* event 2: checks if the word can be found in any cell in the spread sheet (was already present in the previous sentences, so to say)
* event 3: if it does, it loops through all rows (X) and looks in the first column, if the word matches (this is to find out the row's index, which contains the word)
then it adds 1 to the word count in the third column
* event 4: if the word is not contained, the word gets a new row for its own (that's what the push does); since it is a new word, it was not contained in the previous sentence, so the word count in column 2 is 0 and in column 3 is 1
* event 5-6: just loops through the textbox and runs the add_words function for each word; use lowercase(tokenat...) to prevent discerning between Word, word and WORD.
* event 7 and following will do the check, if all words from the previous sentence are contained in the new sentence
* event 8: loops through each row (= each word)
* event 9: if the word was contained at least as many times in the new sentence as in the old one -> everything is fine, the values are set in a way, that the word count of the new sentence becomes the word count for the old sentence
* event 10: if a word was missing one or more times, it adds the amount of times it was missing to the variable wrong
* event 11: checks if no word was missing and throws a success message
* event 12: if at least 1 word was missing, it throws an error message
check the expressions for arrays, if you don't understand one of the actions: https://www.scirra.com/manual/108/array
most important are imo array.at(x,y,z) to read values from the array and, when looping, array.curx, array.cury and array.curz. Width, heigth, depth can help too, but were not really needed in this case.