Complete the code to create a simple function that logs 'Hello World' in the script editor.
function sayHello() {
Logger.[1]('Hello World');
}The Logger class in Google Sheets script editor uses the log method to output messages to the log.
Complete the code to get the active spreadsheet in the script editor.
var spreadsheet = SpreadsheetApp.[1]();The correct method to get the active spreadsheet object is getActiveSpreadsheet(). In code, parentheses are required, but here we only fill the method name without parentheses.
Fix the error in the code to set the value 'Test' in cell A1 of the active sheet.
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); sheet.getRange('A1').[1]('Test');
The correct method to set a single cell's value is setValue with a capital V.
Fill both blanks to create a function that returns the value of cell B2 from the active sheet.
function getCellValue() {
var sheet = SpreadsheetApp.[1]();
return sheet.getRange([2]).getValue();
}To get the active sheet, use getActiveSheet(). To get the value of cell B2, pass the string 'B2' to getRange.
Fill all three blanks to create a function that sets the value 'Done' in cell C3 of the active sheet.
function setDone() {
var sheet = SpreadsheetApp.[1]();
var range = sheet.getRange([2]);
range.[3]('Done');
}Use getActiveSheet() to get the sheet, 'C3' as the cell address, and setValue to set the cell's value.