title: Faster ways to iterate/check the table and replace cell value in google script/javascript?
body: <p>I  have created a table in my google sheet, where days refers to columns and rows refers to trials. <br/></p>
  <p>Day 1 = [O, O, X, X] <br />
  Day 2 = [O, O, X, X] <br /></p>
  <p>However, I want to replace all &quot;O&quot; with some value. These values differ per day. <br/>
  Example: numVal1 = 88 and numVal2 = 99. <br/>
  For day 1, all O must be replaced with 88.  <br/>
  For day 2, all O must be replaced with 99. <br/></p>
  <p>The output must be something like this: <br />
  Day 1 = [88, 88, X, X] <br />
  Day 2 = [99, 99, X, X] <br /></p>
  <p>I'm using a for loop to do this but it's taking too long to finish if I'm working on too many data.  <br />
  My code is: <br /></p>
  <pre><code> for (var i = 1; i &lt;= data.length + 1; ++i){
      for (var j = 1; j &lt;= data[0].length + 1; ++j){
        var item = ws.getRange(i,j).getValue();
        if(item !== &quot;X&quot;){
          let numVal = ws.getRange(6, j).getValue();
          ws.getRange(i,j).setValue(numVal);
        }
      }
    }
  </code></pre>