NEW
Font size
WorksheetsPractice for CPA JavaScript quiz #4
Total questions: 15
Worksheet time: 10mins
Which arithmetic operator could fill in the blank so the following JavaScript expression evaluated to 7?
7 _ 12
/
%
*
+
For var nums = [4, 3, 2, 1, 0]; what is nums[0]?
0
3
4
5
What is 8 % 3?
0
1
2
3
For var nums = [4, 3, 2, 1, 0]; what is nums[4]?
0
3
4
5
How many asterisks would be printed by the following for loop?
for(var i = 0; i < 3; i++){
print('*');
}
0
1
2
3
For var nums = [4, 3, 2, 1, 0]; what is nums[5]?
undefined
3
4
5
Which best matches the elements of nums after the following two lines of code execute?
var nums = [12, -7];
append(nums, 3);
undefined
[12, 3, -7]
[3, 12, -7]
[12, -7, 3]
For var nums = [4, 3, 2, 1, 0]; what is nums.length?
undefined
3
4
5
How many asterisks would be printed by the following for loop?
for(var i = 1; i <= 2; i++){
print('*');
}
0
1
2
3
Which of the following will correctly generate a random integer in the range {2,3,4}?
random(2,4)
random(2,5)
int(random(2,4))
int(random(2,5))
What does the JavaScript command return do?
Adds new items to the end of an array
Ends the function and sends a value back to where the function was called
Calculates the remainder of division with two integers
Ends the loop and continues executing the code after the loop (if any)
Which of the following would correctly replace /* missing code */ so that the function returns the sum of the three arguments?
function sumOfThree(a, b, c) {
/* missing code */
}
x + y + z;
return x + y + z;
a + b + c;
return a + b + c;
What is 10 % 3?
0
1
2
3
What is the output of the following program?
function setup() {
print(mystery(2.5, 2));
}
function mystery(s,t) {
return (s*t)-3;
}
1
2
3
3.5
Which of the following calls to translate would shift a 3d object to the left?
translate(-200, 0, 0);
translate(200, 0, 0);
translate(0, -200, 0);
translate(0, 200, 0);
