
CodeHS Functions and Control Variables
Authored by Katy Fleming
Computers
9th - 12th Grade
Used 116+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
About
This quiz thoroughly examines JavaScript programming fundamentals with an emphasis on functions, parameters, return values, variable scope, and control structures. The content is appropriate for grades 9-12, reflecting an introductory to intermediate computer programming course. Students need a solid understanding of function syntax, including how to define functions with parameters and return statements, how arguments are passed between functions, and the distinction between parameters and arguments. The problems require students to trace through code execution step-by-step, understand variable scope rules including the difference between local and global variables, apply boolean logic operators (&&, ||, !), and comprehend how functions can call other functions or even themselves recursively. Students must also understand loops, string concatenation, and basic program flow to successfully analyze the more complex code-tracing questions. Created by Katy Fleming, a Computers teacher in US who teaches grade 9-12. This quiz serves as an excellent formative assessment tool for students learning fundamental programming concepts in JavaScript. Teachers can use it as a warm-up activity to review function concepts before introducing more advanced topics, assign it as homework to reinforce classroom instruction, or deploy it as a practice quiz before unit tests. The quiz works particularly well for identifying students who struggle with code tracing and variable scope concepts, allowing instructors to provide targeted remediation. The variety of question types—from conceptual understanding to detailed code analysis—makes this suitable for both quick comprehension checks and comprehensive review sessions. This assessment aligns with CSTA K-12 Computer Science Standards, particularly 2-AP-11 (create clearly named variables that represent different data types and perform operations on their values), 2-AP-12 (design programs using control structures and compound expressions), and 3A-AP-17 (decompose problems into smaller components through systematic analysis).
Content View
Student View
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
Why do we write functions?
Make our code easier to understand by giving a readable name to a group of instructions
Avoid writing repeated code
Make our code reusable
All of the above
2.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
In the following function printThreeTimes:
function printThreeTimes(word){
println(word);
println(word);
println(word);
}
What is the parameter of the function?
printThreeTimes
function
println
word
3.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
What is the output of the following program?
function start(){
var x = 5;
sumTo(x);
println(x);
}
function sumTo(num){
var sum = 0;
for(var i = 0; i <= num; i++){
sum += i;
}
println(sum);
}
5
15
15
5
5
15
none, there is a syntax error
4.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
What is printed by the following program?
function printNumbers(two, one, zero){
println(two);
println(one);
println(zero);
}
function start(){
var zero = 0;
var one = 1;
var two = 2;
printNumbers(zero, one, two);
}
2
1
0
0
1
2
zero
one
two
two
one
zero
5.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
How many parameters go into the function sum, and how many return values come out of the function sum?
function sum(first, second, third){
var result = first + second + third;
println(first);
println(second);
println(third);
return result;
}
3 parameters go in, 1 return value comes out
3 parameters go in, 3 return values come out
1 parameter goes in, 4 return values come out
1 parameter goes in, 1 return value comes out
6.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
“It’s a bird! It’s a plane! No, it’s Superman!”
We want to write a function isSuperman that takes in two parameters isBird and isPlane and returns true if it is in fact Superman, and false otherwise.
If it’s not a bird and it’s not a plane, it must be Superman.
Which of the following functions is the correct implementation of isSuperman?
function isSuperman(isBird, isPlane){
return isBird || isPlane;
}
function isSuperman(isBird, isPlane){
return !isBird || !isPlane;
}
function isSuperman(isBird, isPlane){
return !isBird && !isPlane;
}
function isSuperman(isBird, isPlane){
return isBird && isPlane;
}
7.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
In the following code:
function start(){
var length = 5;
var width = 4;
rectangleArea(length, width);
}
// This function prints out the area of
// a triangle given its base and height
function rectangleArea(base, height){
var area = base * height;
println(area);
}
What are the names of the parameters?
length and width
length and height
base and height
base and width
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
13 questions
Pengenalan Aplikasi Blender
Quiz
•
11th Grade
20 questions
Skill Competition Quiz 2024
Quiz
•
10th Grade - University
12 questions
1.2.4. Types of Programming Language
Quiz
•
12th Grade
10 questions
10 câu kiểu xâu tiết 1
Quiz
•
11th Grade
11 questions
Programming Quiz 1
Quiz
•
11th Grade
20 questions
Operator Aritmetika dan Perbandingan
Quiz
•
10th Grade
20 questions
Administrasi Sistem jaringan KD1
Quiz
•
1st - 10th Grade
12 questions
Clase de Computación: Excel
Quiz
•
11th Grade
Popular Resources on Wayground
8 questions
2 Step Word Problems
Quiz
•
KG - University
20 questions
Comparing Fractions
Quiz
•
4th Grade
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Latin Bases claus(clois,clos, clud, clus) and ped
Quiz
•
6th - 8th Grade
22 questions
fractions
Quiz
•
3rd Grade
7 questions
The Story of Books
Quiz
•
6th - 8th Grade