Skip to content

Instantly share code, notes, and snippets.

@phillypb
Created December 23, 2018 09:43
Show Gist options
  • Save phillypb/0e3f20bd1f105188f6b7b54e9b1eecd0 to your computer and use it in GitHub Desktop.
Save phillypb/0e3f20bd1f105188f6b7b54e9b1eecd0 to your computer and use it in GitHub Desktop.
function pushToArray() {
// create an empty array
var students = []
Logger.log('students array starts empty: ' + students);
// array with items to be pushed
var age = [7,8,9];
// loop through each item and push into empy array
for (i=0;i<age.length;i++) {
students.push(age[i]);
}
// log output of new array
Logger.log('students array now contains: ' + students);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment