0% found this document useful (0 votes)
130 views

JavaScript PreTest

This document contains a 15 question quiz about JavaScript knowledge and skills. The questions cover topics like mathematical expressions, conditionals, loops, functions, and basic programming concepts. Multiple choice answers are provided for each question to test understanding of JavaScript syntax and programming logic.

Uploaded by

Danielle Gunter
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views

JavaScript PreTest

This document contains a 15 question quiz about JavaScript knowledge and skills. The questions cover topics like mathematical expressions, conditionals, loops, functions, and basic programming concepts. Multiple choice answers are provided for each question to test understanding of JavaScript syntax and programming logic.

Uploaded by

Danielle Gunter
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

8/24/2018 JavaScript Knowledge & Skills | CodeHS

Name:
Date:
Class:

JavaScript Knowledge & Skills

1. Evaluate the mathematical expression: 3 + 5 x 6 - 4

A. 13
B. 29
C. 33
D. 44

2. If x represents the area of the number line colored blue, which inequality accurately reflects the value of x?

A. x < 6
B. x > 6
C. x ≥ 6
D. x ≤ 6

3. Six identical circles fit inside the rectangle as shown below. If the rectangle has a width of 15 units and a height of 10
units, what is the radius of each circle?

A. 15 units
B. 10 units
C. 5 units
D. 2.5 units

https://codehs.com/quiz/463243/print 1/6
8/24/2018 JavaScript Knowledge & Skills | CodeHS
4. Karel the Dog is instructed to move forward three spaces. Then, if Karel is standing on a ball, Karel will turn right and
move forward two spaces. Otherwise, Karel will turn around and move forward two spaces. Given the starting point
below, where will Karel end up?
Starting Point:

A.

B.

C.

D.

https://codehs.com/quiz/463243/print 2/6
8/24/2018 JavaScript Knowledge & Skills | CodeHS
5. Which of the following describes a task effectively broken into smaller parts?
I. Looking for similarities between different bicycles
II. Ignoring unnecessary details in a math problem
III. Getting ready for school by getting dressed and eating breakfast

A. I and II
B. III only
C. II and III
D. All of the above

6. Consider the following program code:


var sum = 0;
for(var i = 0; i < 5; i++) {
sum += i;
}
println(sum);

What is the result of running this program code?

A. 0 is printed
B. 15 is printed
C. 10 is printed
D. The program results in an infinite loop

7. Consider the following program code:


var x = 4;
var y = 6;
var temp = x;
x = y;
y = temp;

What are the values of x and y as a result of this program code?

A. x has a value of y
y has a value of temp

B. x has a value of 4
y has a value of 6

C. x has a value of 6
y has a value of 4

D. x and y have a value of 4

8. John will buy school lunch if they are serving pizza or grilled cheese and he has more than $10 in his wallet.
Otherwise, John will bring lunch.
In which of the following cases will John buy lunch?

A. John has $8 and they are serving grilled cheese


B. John has $12 and they are serving mac n’ cheese
C. John has $15 and they are serving pizza
D. John has $8 and they are serving pizza

https://codehs.com/quiz/463243/print 3/6
8/24/2018 JavaScript Knowledge & Skills | CodeHS
9. What is the difference between a for loop and a while loop?

A. A for loop repeats commands a specific number of times and a while loop repeats until a condition becomes false.
B. A for loop is used to make decisions between two options and a while loop is used to make decisions between 3 options or
more.
C. A for loop is used when the variable is less than 10 and a while loop is used when the variable is 10 or greater.
D. A for loop is used when we only need to meet one condition and a while loop is used when there are two or more conditions.

10. How many times would the phrase ‘codeHS’ be printed in the following scenario:
repeat 3 times {
repeat 2 times {
println("codeHS");
}
}

A. 3 times
B. 6 times
C. 15 times
D. 5 times

11. What is the total number of times Karel moves when the code below is run?
function moveForward() {
for(var i = 0; i < 5; i++) {
move();
}
}

moveForward();
moveForward();

A. 5
B. 10
C. 20
D. 100

12. What will the following program do when run?


var name = readLine("Name? ");
println("Name is: " + name);

A. The program will ask the user for their name and then will print Name is: with the name they entered
B. The program will ask the user for their name and then will print Name is:

C. The program will print Name is:


D. The program will print Name? and then print Name is:

https://codehs.com/quiz/463243/print 4/6
8/24/2018 JavaScript Knowledge & Skills | CodeHS
13. What would be printed to the screen when the following program is run?
function returnNumber(x) {
return x *5;
}
println(returnNumber(2));

A. 2
B. 5
C. 10
D. 25

14. What will be the ouput of the following program?


var circle = new Circle(100);
circle.setPosition(getWidth()/2, getHeight()/2);
circle.setColor(Color.blue);
add(circle);

A.

B.

C.

D.

https://codehs.com/quiz/463243/print 5/6
8/24/2018 JavaScript Knowledge & Skills | CodeHS
15. What would be the output of the following code?
var number = 6;
if (number < 5) {
println("Hi");
} else {
println("Hello");
}

A. Hi
B. Hello
C. Hi
Hello
D. No output will be printed to the screen

https://codehs.com/quiz/463243/print 6/6

You might also like