1/18
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
1. Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment.
function isEven(num){ if(MISSING CONDITION){ return true; } else { return false; } }
A. num % 2 == 0;
B. num % 0 == 2;
C. num % 1 == 0;
D. num % 1 == 2;
A. num % 2 == 0;
What will be printed to the console after this program runs?
var numbers = [2, 5, 3, 1, 6] function changeNums(numList, addNum, subtractNum){ for(var i=0; i
B. [0, 3, 6, -1, 9]
which function calls would provide the most helpfu test of this function?
function findMin (num1,num2){
if (num1 < num2){
return num1:
}else{
return num2;
D. findMin(-1,1)
findMin(1,-1)
findMin(1,1)
7.
What is printed to the console?
console.log(15 % 4);
A. 2
B. 3
C. 4
D. 1
B. 3
8.
Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems.
A. procedural abstraction
B. API
C. parameter
D. library
A. procedural abstraction
9.
This function checks if a character is a vowel. If it is, it returns true. Otherwise, it returns false.
Where should return false; be written in the code?
function checkVowel(character){ var vowels = ["a", "e", "i", "o", "u"]; for(var i=0; i
C. OPTION C
10.
This function finds the minimum number in a list. What should
function min(numList){ var min = numList[0]; for(var i=0; i
A. numList[i] = min;
B. min = numList[i];
C. min = numList;
D. numList = min;
B. min = numList[i];
11.
Algorithms can be created in all the following ways EXCEPT:
A. creating from an idea
B. combining existing algorithms
C. removing sequencing, selection, and iteration from an algorithm
D. modifying existing algorithms
C. removing sequencing, selection, and iteration from an algorithm
12.
Using existing algorithms as building blocks for new algorithms has all the following benefits EXCEPT:
A. reduces development time
B. reduces testing
C. simplifies debugging
D. removes procedural abstraction
D. removes procedural abstraction
13.
What is one of the benefits of using a library in a program?
A. simplifies creating a complex program
B. increases development time
C. removes all testing
D. reduces abstractions in the program
A. simplifies creating a complex program
14.
Which call of the function correctly follows the instructions laid out in the API?
A. moveElement("button1", 2, 23);
B. moveElement("button1", "left", "thirty");
C. moveElement("button1", 30, "two");
D. moveElement("button1", "down", 25);
D. moveElement("button1", "down", 25);
15.
Dividing a program into separate subprograms (such as libraries) is known as:
A. modularity
B. iteration
C. API
D. documentation
A. modularity
Which code segment will guarantee that the robot makes it to the grey square without hitting a wall or a barrier (black square
} bfunction solveMaze( )
{ moveForward();
moveForward();
rotateRight ();
while (canMove("forward")){ moveForward(); } rotateLeft();
moveForward();
11 What is one of the benefits of using a library in a program?
simpli!es creating a complex program
Library
a group of functions (procedures) that may be used in creating new programs
Argument
the value passed to the parameter
Return
used to return the flow of control to the point where the procedure (also known as a function) was called and to return the value of expression.
API
Application Program Interface - specifications for how functions in a library behave and can be used
Modularity
The subdivision of a computer program into separate subprograms