• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 8 pages
Exam (elaborations)

Javascript Control Structures Exam Questions With Correct Answers

Document preview thumbnail
Preview 2 out of 8 pages

JAVASCRIPT CONTROL STRUCTURES EXAM QUESTIONS WITH CORRECT ANSWERS

Content preview

JAVASCRIPT CONTROL
STRUCTURES EXAM QUESTIONS
WITH CORRECT ANSWERS

In the following code, what will be the last number to print to the screen before the
program finishes?

for (var i = 0; i < 10; i++) {
if (i % 2 == 0) {
println(i);
} else {
println(2 * i);
}
} - Answer- 18

4.5.4: Meme Text Generator - Answer- function start(){
for(var i = 0; i < 50; i++){
println("I will not come to school late.");
}
}

4.5.5: The Worm - Answer- var NUM_CIRCLES = 15;

function start(){

for(var i = 0; i < 15; i++){
var circle = new Circle(NUM_CIRCLES);
circle.setPosition(i, 200);
circle.setColor(Color.grey);
add(circle);
}
}

4.5.6: Caterpillar - Answer- var NUM_CIRCLES = 15;
function start(){
for(var i = 0; i < 15; i++){
var circle = new Circle(NUM_CIRCLES);
if (i % 2 == 0) {
circle.setPosition(i, 200);
circle.setColor(Color.red);
add(circle);

, } else {
circle.setPosition(i, 200);
circle.setColor(Color.green);
add(circle);
}
}
}

How many times will the following code print "hello"?

for (var i = 3; i < 8; i++) {
println("hello");
} - Answer- 5 **YES AGAIN

How many times will the following code print "hello"?

for (var i = 0; i < 8; i += 2) {
println("hello");
} - Answer- 4

4.6.5: Count By Sevens - Answer- function start(){
for(var i = 0; i <= 500; i += 7){
println(i);
}
}

4.6.6: Powers of Two - Answer- function start(){
for(var i = 1; i <= 1000000; i *= 2){
println(i);
}
}

Why do we use constant variables? - Answer- All of the Above

Which of the following is a good example of a proper constant variable name? - Answer-
var MAX_VALUE = 100;

What will be the value of sum after this code runs?

var START = 1;
var END = 4;

function start(){
var sum = 0;
for(var i = START; i <= END; i++){
sum += i;

Document information

Uploaded on
September 12, 2025
Number of pages
8
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$17.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
wisdompoint
3.7
(20)
Sold
120
Followers
66
Items
5730
Last sold
4 months ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions