0
0
Google Sheetsspreadsheet~20 mins

Custom functions in Google Sheets - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Custom Functions Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📊 Formula Result
intermediate
1:30remaining
Output of a simple custom function
You created this custom function in Google Sheets:
function DOUBLE(input) { return input * 2; }

What will be the output in cell A1 if you enter =DOUBLE(5)?
Google Sheets
function DOUBLE(input) { return input * 2; }
A5
B10
CError: Function not found
D25
Attempts:
2 left
💡 Hint
Think about what doubling 5 means.
Function Choice
intermediate
2:00remaining
Choosing the correct custom function for text manipulation
You want a custom function that takes a text string and returns it in uppercase.
Which of these custom functions will work correctly in Google Sheets?
Afunction TOUPPER(text) { return text.toUpper(); }
Bfunction TOUPPER(text) { return text.uppercase(); }
Cfunction TOUPPER(text) { return UPPER(text); }
Dfunction TOUPPER(text) { return text.toUpperCase(); }
Attempts:
2 left
💡 Hint
JavaScript strings have a method to convert to uppercase.
📊 Formula Result
advanced
2:30remaining
Output of a custom function with array input
Given this custom function:
function SUMPLUSONE(range) {
  let sum = 0;
  for (let i = 0; i < range.length; i++) {
    sum += range[i][0];
  }
  return sum + 1;
}

What is the output of =SUMPLUSONE(A1:A3) if cells A1=2, A2=3, A3=4?
Google Sheets
function SUMPLUSONE(range) {
  let sum = 0;
  for (let i = 0; i < range.length; i++) {
    sum += range[i][0];
  }
  return sum + 1;
}
A10
B9
CError: Cannot read property '0' of undefined
D7
Attempts:
2 left
💡 Hint
Sum the values 2 + 3 + 4, then add 1.
🎯 Scenario
advanced
2:00remaining
Debugging a custom function that returns #NAME!
You wrote this custom function:
function CONCATENATE_TWO(a, b) {
  return a + b;
}

When you use =CONCATENATE_TWO("Hello", "World") in your sheet, it shows #NAME!.
What is the most likely reason?
Google Sheets
function CONCATENATE_TWO(a, b) {
  return a + b;
}
ACustom functions must be declared with 'function myFunction()' only.
BThe script is missing the <code>function</code> keyword.
CThe script file is not saved.
DThe function name must be lowercase.
Attempts:
2 left
💡 Hint
Think about what happens if the script is not properly saved.
data_analysis
expert
3:00remaining
Analyzing output of a custom function with nested arrays
Consider this custom function:
function FLATTEN_AND_SUM(input) {
  let flat = input.flat();
  return flat.reduce((a, b) => a + b, 0);
}

If you enter =FLATTEN_AND_SUM({1,2;3,4}) in a cell, what is the output?
Google Sheets
function FLATTEN_AND_SUM(input) {
  let flat = input.flat();
  return flat.reduce((a, b) => a + b, 0);
}
A10
BError: input.flat is not a function
C7
DNaN
Attempts:
2 left
💡 Hint
The input {1,2;3,4} is [[1,2],[3,4]], flat() gives [1,2,3,4], sum is 10.