Complete the code to define a custom function that adds two numbers in Google Sheets.
function addNumbers(a, b) {
return a [1] b;
}- instead of plus +.* or division / by mistake.The plus sign + adds two numbers together in JavaScript, which is used for Google Sheets custom functions.
Complete the code to return the uppercase version of a text input in a custom function.
function toUpperCase(text) {
return text.[1]();
}lowercase() which does the opposite.capitalize() which is not a standard JavaScript method.The toUpperCase() method converts text to all uppercase letters in JavaScript.
Fix the error in the custom function that should return the square of a number.
function squareNumber(num) {
return num [1] 2;
}^ which is a bitwise XOR, not exponent.* which multiplies but does not square.The ** operator in JavaScript means 'to the power of'. So num ** 2 squares the number.
Fill both blanks to create a custom function that returns the first letter of a text in uppercase.
function firstLetterUpper(text) {
return text.[1](0, 1).[2]();
}trim() which removes spaces, not letters.substring but forgetting to convert to uppercase.slice(0, 1) extracts the first letter, and toUpperCase() converts it to uppercase.
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.
function wordLengths(words) {
let result = {};
for (let word of words.flat()) {
if (word.[1] > [2]) {
result[word] = word.[3];
}
}
return result;
}size which is not a string property in JavaScript.word.length gives the length of the word. We check if it's greater than 3, then store the length in the result.