# Google Apps Script Quiz 4

Question 1: Which of the following is not a data type in Google Apps Script?
Question 2: What is the output of the following code?
Question 3: What is the correct syntax for defining a function in Google Apps Script?
Question 4: Which of the following is not a valid loop structure in Google Apps Script?
Question 5: What is the output of the following code?
Question 6: Which of the following methods can be used to convert a string to a number in Google Apps Script?
Question 7: What is the output of the following code?
Question 8: Which of the following is not a valid comparison operator in Google Apps Script?
Question 9: What is the output of the following code?
Question 10: Which of the following is not a valid way to declare an array in Google Apps Script?

# Question 1: Which of the following is not a data type in Google Apps Script?

A) String

B) Boolean

C) Integer

D) Double

Solution: C) Integer

var x = 10;

var y = 5;

var z = x + y;

Logger.log(z);

A) 10

B) 5

C) 15

D) Error

Solution: C) 15

# Question 3: What is the correct syntax for defining a function in Google Apps Script?

A) function myFunction() {}

B) def myFunction() {}

C) var myFunction() {}

D) function = myFunction() {}

Solution: A) function myFunction() {}

# Question 4: Which of the following is not a valid loop structure in Google Apps Script?

A) for loop

B) while loop

C) do-while loop

D) foreach loop

Solution: D) foreach loop

var x = “5”;

var y = 10;

var z = x + y;

Logger.log(z);

A) 15

B) 510

C) Error

D) undefined

Solution: B) 510

# Question 6: Which of the following methods can be used to convert a string to a number in Google Apps Script?

A) Number()

B) parseInt()

C) parseFloat()

D) All of the above

Solution: D) All of the above

# Question 7: What is the output of the following code?

var x = true;

var y = false;

Logger.log(x && y);

A) true

B) false

C) Error

D) undefined

Solution: B) false

A) ==

B) !=

C) <=

D) ><

Solution: D) ><

# Question 9: What is the output of the following code?

var x = [1, 2, 3];

Logger.log(x.length);

A) 3

B) “1, 2, 3”

C) Error

D) undefined

Solution: A) 3

# Question 10: Which of the following is not a valid way to declare an array in Google Apps Script?

A) var arr = [1, 2, 3];

B) var arr = new Array(1, 2, 3);

C) var arr = {1, 2, 3};

D) All of the above are valid

Solution: C) var arr = {1, 2, 3};