title: Resetting Arrays for Each Iteration in a Loop
body: <p>I am searching through a set of strings for a set of keywords. Then, if certain combinations of words are present, I'm assigning given point values to a scorekeeping array.</p>
  
  <p>As I iterate through the strings, I modify these arrays to keep track of information on a specific string. I want to print the scores ranked high to low, and then reset the values in the arrays to their original assignments.</p>
  
  <p>Therefore, I need a way to create a new object to modify at the beginning of each iteration so that I can preserve my original arrays.</p>
  
  <p>I've tried to define a variable outside the loop and then use .slice(), Object.create(), and [...arr], but I have not been successful.</p>
  
  <p>The only way I can get the function to work is by defining the array at the beginning of the loop using literal notation (This is okay, but if I need to build an object with hundreds of keywords for each of hundreds of notes, I'm worried it will slow down processing time).</p>
  
  <pre><code>  const keyMast = [ //pre-decided keywords, set to false
      ["No Word", true],
      ["elbow", false],
      ["ss" , false], 
      ["student" , false],
      ["read", false]
    ];  
    const combos = [ //for each set of words, assings values for T1, T2,... 
      ["student", true, true, 1, 2, 3, 0, 0, 0, 0, 0],
      ["elbow", true, true, 3, 2, 1, 0, 0, 0, 0, 0],
      ["student", "read", true, 0, 0, 0, 1, 2, 3, 0, 0],
      ["talk", "read", true, 0, 0, 0, 0, 0, 1, 2, 3]
    ];
    const scoreMast= [ //master list of Ts set to zero
      ["T1", 0],
      ["T2", 0],
      ["T3", 0],
      ["T4", 0],
      ["T5", 0],
      ["T6", 0],
      ["T7", 0],
      ["T8", 0]
    ];
  
  
  
    //this loop grabs each line in the notes
    var i=6; //the first line of notes starts in Cell B6
    do {
      //reset values for our tables after each note
      tempCombo = [...combos];
      tempKeywords = [...keyMast];
      tempScore = [...scoreMast];
      //do stuff with the lists on this line of notes
  </code></pre>
  
  <p>Like I said, I have tried a bunch of different strategies, but nothing seems to yield new objects with identical properties as score, keywords, and combos for each iteration.</p>
  
  <p>Two questions: is it easier to just define the variables inside the loop using literal notation (var combo = [ [blah, blah], []])? Will that slow my code down?</p>
  
  <p>Either way, I'd love to know how to do this for generality's sake.</p>
  
  <p>EDIT
  Tanaike asked for outputs. The Do Loop needs to sort the scores and then runs</p>
  
  <pre><code>var suggest = tempScores[0][0] + " " + tempScores[1][0] + " " +tempScores[2][0]
  Ss.getRange(i,3). setValue(suggest)
  </code></pre>
  
  <p>My clients are principals. When they observe teachers, they assess their work on 8 Teaching Standards (hence, T1, T2...). They want to take notes during a lesson and then have the spreadsheet suggest which standards most closely align on that line of notes based on keywords they use.</p>