0
0
Google Sheetsspreadsheet~10 mins

Custom functions 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 define a custom function that adds two numbers in Google Sheets.

Google Sheets
function addNumbers(a, b) {
  return a [1] b;
}
Drag options to blanks, or click blank then click option'
A/
B+
C*
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using minus - instead of plus +.
Using multiplication * or division / by mistake.
2fill in blank
medium

Complete the code to return the uppercase version of a text input in a custom function.

Google Sheets
function toUpperCase(text) {
  return text.[1]();
}
Drag options to blanks, or click blank then click option'
Alowercase
Btrim
Ccapitalize
DtoUpperCase
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase() which does the opposite.
Using capitalize() which is not a standard JavaScript method.
3fill in blank
hard

Fix the error in the custom function that should return the square of a number.

Google Sheets
function squareNumber(num) {
  return num [1] 2;
}
Drag options to blanks, or click blank then click option'
A**
B+
C*
D^
Attempts:
3 left
💡 Hint
Common Mistakes
Using ^ which is a bitwise XOR, not exponent.
Using * which multiplies but does not square.
4fill in blank
hard

Fill both blanks to create a custom function that returns the first letter of a text in uppercase.

Google Sheets
function firstLetterUpper(text) {
  return text.[1](0, 1).[2]();
}
Drag options to blanks, or click blank then click option'
Aslice
BtoUpperCase
Csubstring
Dtrim
Attempts:
3 left
💡 Hint
Common Mistakes
Using trim() which removes spaces, not letters.
Using substring but forgetting to convert to uppercase.
5fill in blank
hard

Fill all three blanks to create a custom function that returns a dictionary with words as keys and their lengths as values, but only for words longer than 3 letters.

Google Sheets
function wordLengths(words) {
  let result = {};
  for (let word of words.flat()) {
    if (word.[1] > [2]) {
      result[word] = word.[3];
    }
  }
  return result;
}
Drag options to blanks, or click blank then click option'
Alength
B3
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Using size which is not a string property in JavaScript.
Comparing length to a string '3' instead of number 3.