Basic JavaScript | Math and Graphics | Miscellaneous JS | booleans, comparison and logical operators | Foor Loops |
---|---|---|---|---|
What is a string?
println("Hello world.");
In this program, hello world is an example of this. |
What is getWidth() / 2
In a graphics program, I would use this to place the shape in the center of the canvas.
|
What is a variable?
This is used to store information, like a box.
|
True/false
What is a boolean?
|
What is 0?
In this example, it will set (start) the variable at what number?
for(var i = 0; i < 30; i++){ |
What is Camel Case?
var myVarName;
In this example the variable is written in this case. |
WHat is the radius?
var circle = new Circle(50);
In this example, 50, stands for this. |
What is &&
These symbols represents the "and" operator in JavaScript?
|
What is ==
This is the correct comparison operator to use when two numerical values are equal.
|
What is 400?
How many times will this code execute?
for(var i = 0; i < 400; i++{ |
What is "readInt"?
If I need a user to input an answer that is a number, I would use this.
|
What is upper left?
To set location of the ____ _____corner of rectangle
we use rect.setPosition(x, y); |
var numApples = 20;
Write a variable that indicates there are 20 apples.
|
What is an if/else statement?
You could use this in a program that needs to figure out whether one this is true, then it would print one thing, otherwise, it would print something else.
|
for(var i = 0; i < 10; i++){
println(i); }
Write a forLoop that Prints numbers 0-9 starting at 0 and going up in increment by 1 each time.
|
What is "readBoolean"?
If I had a true/false question for the user, I would use this.
|
What is add one?
In math, any number with a ++ behind it means to do this.
|
function start(){
var dog= readLine("Do you have a dog ?"); var num= readInt("How many dogs ?"); println(dog + num); }
Write a program that asks a user if they have a dog, and then asks how many dogs they have, then print the line at the end.
|
What is
I would use this to indicate "or" in a JS program.
|
What is 5?
How many times will the following code print "hello"?for (var i = 3; i < 8; i++) { println("hello");}
|
What is !=
This is how you would write this in JavaScript
"not equal" |
var COST_OF_PIZZA = 10.00;
function start () { var numPizza = readInt(" How many pizzas do you want "); var total = (numPizza * COST_OF_PIZZA); println(total); }
I need an unknown number of pizzas and each cost 10.00. Write a program to find the total.
|
What is add(circle);
What is missing in this program?
function start(){ 2 var circle = new Circle(40); 3 circle.setPosition(getWidth() / 2, getHeight() / 2); 4 circle.setColor(Color.blue); 5 } |
What is three?
var correctIngredients var recipe var canMakeCookies
You need a program that figures whether or not someone has the correct ingredients and has the recipe to make gramma's fave cookies. How many variables would you need to have in this scenario?
|
The variable will start at 1 and multiply that answer by two until it reaches 1 million.
Explain this for loop and how it works
for (var i = 1; i < 1000000; i *= 2){ |