0
0
Google Sheetsspreadsheet~10 mins

Script editor overview in Google Sheets - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a simple function that logs 'Hello World' in the script editor.

Google Sheets
function sayHello() {
  Logger.[1]('Hello World');
}
Drag options to blanks, or click blank then click option'
Aprint
Bwrite
Clog
Dshow
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of log causes an error because print is not a Logger method.
Using write or show are not valid Logger methods.
2fill in blank
medium

Complete the code to get the active spreadsheet in the script editor.

Google Sheets
var spreadsheet = SpreadsheetApp.[1]();
Drag options to blanks, or click blank then click option'
AgetActiveSheet
BgetActiveSpreadsheet
CgetActive
DgetActiveSpreadsheet()
Attempts:
3 left
💡 Hint
Common Mistakes
Using getActiveSheet returns a sheet, not the spreadsheet.
Using getActive without Spreadsheet is invalid.
3fill in blank
hard

Fix the error in the code to set the value 'Test' in cell A1 of the active sheet.

Google Sheets
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.getRange('A1').[1]('Test');
Drag options to blanks, or click blank then click option'
Aset_val
Bsetvalue
CputValue
DsetValue
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'setvalue' causes a method not found error.
Using 'putValue' or 'set_val' are not valid methods.
4fill in blank
hard

Fill both blanks to create a function that returns the value of cell B2 from the active sheet.

Google Sheets
function getCellValue() {
  var sheet = SpreadsheetApp.[1]();
  return sheet.getRange([2]).getValue();
}
Drag options to blanks, or click blank then click option'
AgetActiveSheet
BgetActiveSpreadsheet
C'B2'
D'A1'
Attempts:
3 left
💡 Hint
Common Mistakes
Using getActiveSpreadsheet instead of getActiveSheet returns the spreadsheet object, which does not have getRange.
Using 'A1' instead of 'B2' returns the wrong cell.
5fill in blank
hard

Fill all three blanks to create a function that sets the value 'Done' in cell C3 of the active sheet.

Google Sheets
function setDone() {
  var sheet = SpreadsheetApp.[1]();
  var range = sheet.getRange([2]);
  range.[3]('Done');
}
Drag options to blanks, or click blank then click option'
AgetActiveSheet
B'C3'
CsetValue
DgetActiveSpreadsheet
Attempts:
3 left
💡 Hint
Common Mistakes
Using getActiveSpreadsheet instead of getActiveSheet causes errors when calling getRange.
Using wrong cell address or method names causes runtime errors.