CSP Unit 7 Parameters, Return, and Libraries Assessment Flashcards Quizlet
CSP Unit 7 Parameters, Return, and Libraries Assessment Flashcards Quizlet
}
return false;
} else {
return true;
if(MISSING CONDITION){
function isEven(num){ num % 2 == 0;
CONDITION" with the correct code segment.
returned if a number is even? Replace "MISSING
Which code segment results in "true" being
1 / 15
Flashcards Learn
Test Match
Q-Chat
sofiaelise_ Share
Created 2 years ago
20 terms 15 terms
function
isEven(num){
if(MISSING
CONDITION)
{
return true;
} else {
return false;
}
}
// checks if a robot
can move in any
direction
// direction {string}
- the direction to
be checked
// return {Boolean}
- true if the robot
can move in that
direction, otherwise
returns false
function
canMove(direction);
Which code
segment will
guarantee that the
robot makes it to
the gray square
without hitting a
wall or a barrier
(black square)?
function
changeNums(numList,
addNum,
subtractNum){
for(var i=0;
i<numList.length; i++){
if(numList[i] % 3 == 0){
numList[i] = numList[i] +
addNum;
} else {
numList[i] = numList[i] -
subtractNum;
}
}
}
changeNums(numbers,
3, 2);
console.log(numbers);
Which findMin(-1, 1)
function calls findMin(1, -1)
would findMin(1, 1)
provide the
most helpful
test of this
function?
Remember:
With tests,
you are
attempting to
figure out all
the possible
ways the
function
could be
broken.
function
findMin(num1,
num2){
if(num1 <
num2){
return num1;
} else {
return num2;
}
}
What is 3
printed to the
console?
console.log(15
% 4);
function
checkVowel(character)
{
var vowels = ["a", "e", "i",
"o", "u"];
for(var i=0;
i<vowels.length; i++){
if(vowels[i] ==
character){
return true;
OPTION A
}
OPTION B
}
OPTION C
}
OPTION D
function
min(numList){
var min =
numList[0];
for(var i=0;
i<numList.length;
i++){
if(numList[i] <
min){
<MISSING
CODE
SEGMENT>
}
}
return min;
}
// moves a
given element
on the screen
// id (string) -
the element ID
for the item to
be moved
// direction
(string) - the
direction the
element should
be moved
// amount
(number) - the
amount of pixels
the element
should be
moved
function
moveElement(id,
direction,
amount) {
var xPosition =
getXPosition(id);
var yPosition =
getYPosition(id);
if (direction ==
"left") {
setProperty(id,
"x", xPosition -
amount);
} else if
((direction ==
"right")) {
setProperty(id,
"x", xPosition +
amount);
} else if
((direction ==
"up")) {
setProperty(id,
"y", yPosition -
amount);
} else {
setProperty(id,
"y", yPosition +
amount);
}
}
Dividing a Modularity.
program into
separate
subprograms
(such as
libraries) is
known as:
Get the app Q-Chat: your AI tutor Quizlet Plus for teachers Privacy
Language
English (USA)
Country
United States Canada United Kingdom Australia New Zealand Germany France Spain Italy
Japan South Korea India China Mexico Sweden Netherlands Switzerland Brazil Poland