0% found this document useful (0 votes)
53 views6 pages

JavaScript Programming Quiz Overview

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views6 pages

JavaScript Programming Quiz Overview

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

[Link] 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.

[Link] 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

[Link] 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:

[Link] 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);
[Link](getWidth()/2, getHeight()/2);
[Link]([Link]);
add(circle);

A.

B.

C.

D.

[Link] 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

[Link] 6/6

Common questions

Powered by AI

Abstraction allows focusing on essential features by removing unnecessary details, facilitating task breakdown. For example, ignoring unnecessary details in a math problem or organizing morning routines into distinct activities like dressing and eating breakfast, helps streamline processes and make tasks more manageable .

The program uses an if-else structure to check if 'number' is less than 5. Since the condition (number < 5) evaluates to false (as number is 6), the else block executes, resulting in 'Hello' being printed. This illustrates the straightforward use of conditional logic to determine program output .

The JavaScript code creates a circle with a specific radius and positions it at the center of the screen by setting its x and y coordinates to half the screen's width and height, respectively. Its color is set to blue to ensure the display output is visually clear, confirming the program is functioning as intended .

The function returnNumber(x) returns the input x multiplied by 5. When called with input 2, the function computes 2 * 5, resulting in an output of 10. The println statement then outputs this returned value .

The program initializes 'sum' to 0 and uses a for loop iterating five times (i = 0 to 4), adding each value of 'i' to 'sum'. The sequence of additions: 0 + 0 + 1 + 2 + 3 + 4 results in a final value of 10 for 'sum' after all iterations are completed .

The correct evaluation of the expression 3 + 5 x 6 - 4 is 29. According to the order of operations, multiplication is performed before addition and subtraction. Thus, 5 x 6 yields 30, resulting in the expression 3 + 30 - 4. Finally, performing addition and subtraction from left to right gives 33 - 4, equaling 29 .

A 'for loop' is used to repeat commands a specific number of times, typically when the number of iterations is known beforehand, as it includes an initialization, condition, and increment/decrement in its syntax. In contrast, a 'while loop' repeats its commands until a specific condition becomes false, making it more suitable for scenarios where the iteration count is not known in advance .

John will buy school lunch if they are serving either pizza or grilled cheese and he has more than $10 in his wallet. The correct scenario is when John has $15 and they are serving pizza. This meets both conditions: serving one of the preferred meals (pizza) and having more than $10 .

The rectangle has a width of 15 units and a height of 10 units. Since six identical circles fit within it, each circle has a diameter equal to the shorter dimension of the rectangle, which is 10 units. Consequently, the radius of each circle is 5 units, since radius is half of the diameter .

Karel moves forward three spaces initially. If standing on a ball, Karel will turn right and move forward two more spaces; otherwise, Karel turns around and moves forward two spaces. Thus, Karel's final position depends on the initial state regarding whether it starts on a ball .

You might also like