I code with Google Apps Script which is based on JavaScript. How do I code… I copy and paste. There is a TON of sample code out on the Internet that you can steal. At first, I would copy and paste code. Then I would need to read through it and figure out what I needed to adjust. I copy and paste a lot less code now, by using “analyze over memorize” I got this!

Breaking Down the Code

1. function

You can have more than one function. A function is a chunk of code. It starts with lowercase function and then a space and then what you want to name the function. Note that your function name can not have a space. To use more than one word, smash the words together and capitalize the 2nd word.

Remember function notation from algebra? f(x) = x + 2.
The function f has a parameter (x). If you had f(5) you would replace all the x’s with 5’s. f(5) = (5) + 2.
It’s like that!!! Except usually, I do not have parameters when I code so it’s more like f().
So you need the empty parenthesis to say that your function does not have parameters!

2. Curly Braces

Curly braces trap the code for that function.

3. What App Are You Using?

Typically my first line of code is “What Google App are you using?” In this case I am coding a Google Doc so it is DocumentApp. Notice the capital D and A. It’s important.

4. Period

When you type a period in Google Apps Script it will give you a multiple choice menu for what methods (code) you can use. The awesome thing about Google Apps Script is that it is super readable!

5. Create

Reading the list of multiple choice options one of them says “Create().” I KNOW WHAT THAT DOES! It will create a Google Doc. In the parenthesis you can name the Google Doc you are creating! I named mine ‘Alice Keeler Document.’ Notice the single quotations! All text strings (stuff you want to type) must be in quotations.

6. Semicolon

At the end of each line of code you want to have a semicolon!

Save and Run

Modify something small! (Hoping you changed what I named the document) then press the save button (or Control S) and press the Run button (triangle icon.) You will be prompted to name the script and authorize the script. You may get a screen that has a button that says “Return to safety.” Ignore that button and click on “Advanced” and then click on the link that says “unsafe” (it is safe, you coded it so you know it is not malicious code.)

Check Google Drive

You just created a Google text document. Check recent to see if it worked!

Now Modify

We used DocumentApp to create a new Google Doc. Do you think you can create another type of Google App?

SlidesApp
FormApp
SpreadsheetApp
CalendarApp
MapsApp
ContactsApp
DriveApp
GmailApp

DocumentApp

On the Google Apps developer site is sample code you can copy and paste!! Check out this page for DocumentApp. Scroll through and find code that you can copy and paste!