google apps script - Not sure why changing a variable value changes the array element which I used to declare it -


i have array has date in 3rd column, , wrote following script calculate friday on or after day. script works (after little trouble) unfortunately while adds new column, overwrites column 3 friday date.

any advise appreciated.

  logger.log("started week ending");   newdata[0].push("week ending");    for(i = 1; < newdata.length; i++) {     l = newdata[i][2] ;     for(;l.getday() != 5;) {       l.setdate(l.getdate()+1);     }      newdata[i].push(l);   } 

basically want variable "lowercase l" change value not source of value newdata[i][2]. idea doing wrong?

i first posted in google docs forum , advised might find more here. since posting, tried variation of part of code instead directly filling array , manipulating new column value instead of intermediate variable. code below:

  logger.log("started week ending");   newdata[0].push("week ending");    for(i = 1; < newdata.length; i++) {     newdata[i].push(newdata[i][2]) ;     for(;newdata[i][20].getday() != 5;) {       newdata[i][20].setdate(newdata[i][20].getdate()+1);     }    } 

thank looking! eric


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -