Editable text input for loop JavaScript error

URL of experiment: https://run.pavlovia.org/tzhu9/written_response/html/

In my experiment, I want to compare participants’ input (stored in a var called text.text) to correct answer (stored in a var called final_words), and return matched words in an array called matched_words.

text.text is an array of letters, whereas final_words is an array of words. When I ran my experiment online, I get this
TypeError: text.text.join is not a function

Below is my JavaScript code relating to this issue

for (let word of final_word) {
   if(text.text.join("").toLowerCase().contains(word)) {

Can someone spot what the issue is?

Hi @tokaalmighty are you sure text.text is an array? What is the return value of Array.isArray(text.text)?

I looked at my data file and text.text column only has the words, not quotations around letters. How should I change the code if it wasn’t array, I’m actually not sure what data type it is.

I changed the code to
still does what I need, and no errors

My best guess would be that text.text is a string, could you try the following?

// Divide input into words
const wordsOfText = text.text.split(' ');

for (let word of wordsOfText) {
  if (final_words.includes(word)) {