Java script Graphics and Control Structures

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What is the proper operator for "not equals" in JavaScript?

!=

What symbol represents the and operator in JavaScript?

&&

How can we check if a variable num is even?

(num % 2 == 0) will be true

What symbol do you use to do multiplication in JavaScript?

*

What symbol do you use to do division in JavaScript?

/

What function do you need to call to get the width of the screen?

screenWidth()

What is the term for the value that signals the end of user input?

sentinel

After the following code runs, what is the value of isWeekend? var isSaturday = true; var isSunday = false; var isWeekend = isSaturday || isSunday;

true

What keyword do you need to use to define a variable in JavaScript?

var

Which of the following is a good example of a proper constant variable name?

var MAX_VALUE = 100;

Which of the following returns a random number between 1 and 10?

Randomizer.nextInt(1, 10)

In the following code, we create a circle and add it to the screen. What is the meaning of the x variable? var x = 20; var circle = new Circle(x); add(circle);

The radius of the circle

How many times will this program print "hello"? var i = 50; while (i < 100) { println("hello"); }

This code will loop infinitely

What is the proper way to compare if two values are equal in a boolean expression in JavaScript?

==

Why do we use constant variables?

All of the above

To ask the user of the program for a number, which function should you use?

Both readInt and readFloat are for numbers.

How many times will this program print "hello"? var i = 10; while (i > 0) { println("hello"); i--; }

10

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; } }

10

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); } }

18

How many possible values can Randomizer.nextBoolean() return?

2

How many times will the following code print "hello"? for (var i = 0; i < 8; i += 2) { println("hello"); }

4

What will the following code print to the screen? println(2 + 2);

4

How many times will the following code print "hello"? for (var i = 3; i < 8; i++) { println("hello"); }

5

How many times will the following program print "hello"? for (var i = 0; i < 5; i++) { println("hello"); }

5

What statement can we use inside of a loop to end it?

break

What are the coordinates of the top right corner of the screen?

getWidth(), 0

What kind of statement allows us to run a block code only if a certain condition is true?

if statement

What kind of statement allows us to run one block of code if one condition is true, and a separate block of code otherwise?

if/else statement

What is the proper function to call to print to the screen?

println

What function do you need to call to ask the user of the program to enter text?

readLine

Which of the following is correct loop and a half structure?

while(true){ //code if(condition){ break; } //code }

Which of the following is not a valid value for a boolean?

yes

What symbol represents the or operator in JavaScript?

||


Set pelajaran terkait

Chapter 23: Body Mechanics, Positioning, & Moving

View Set

Psychology Chapter 3 study guide

View Set