The first statement inside the parenthesis of the for loop. (ie. for( ; ; ))
What is the initial value for the loop variable?
What is 1 a placeholder for?
1
while( 2 ){
3
}
4
The location of the loop variable initialization:
The error(s) in the following code:
for(i = 0; i<20; i++);
console.log(i);
What is...
for(var i=0; i<20; i++)
console.log(i);
The second statement inside the parenthesis of the for loop. (ie. for( ; ; ))
What is the loop condition?
What is 2 a placeholder for?
1
while( 2 ){
3
}
4
the loop condition?
The statement inside of the parenthesis of a while loop. (ie. while( ___ ))
Fix the error(s) in the following code:
While(i<100);
console.log(i);
var i=0;
while(i<100)
{
console.log(i);
i++;
}
The third statement inside the parenthesis of the for loop. (ie. for( ; ; ))
What is the action step? (or What is the increment/decrement to the loop variable?)
What is 3 a placeholder for?
1
while( 2 ){
3
}
4
The location of the loop variable action (increment/decrement).
The error(s) in the following code:
for(int i=0; i<10; i++)
i+=3;
console.log(i);
What is...
for(int i=0; i<10; i++)
{
i+=3;
console.log(i);
}___
The output of:
for(int i=1;i<=10;i++)
{
console.log(i + " ");
}
"1 2 3 4 5 6 7 8 9 10"
What is the output of:
int j = 3;
while ( j <= 11)
{
console.log(j + “ ”);
j+=2;
}
"3 5 7 9 11"
The error(s) in the following code:
var x = 10;
while(5 < x < 20)
{
console.log(x)
x += 5;
}
What is...
var x = keyboard.nextInt();
while(5 < x && x < 20)
{
console.log(x);
x+=5;
}
The output for:
int sum = 0;
for(int i = 0; i< 12; i+=2){
sum += i;
console.log(sum);
}
console.log(sum);
30 (How?? sum = 0 + 2 + 4 + 6 + 8 + 10 = 30)
What is the output of:
int n=0, count=0;
while(n<8) {
count += n;
n+=2;
}
console.log( count );
12
The error(s) in the following code:
int x = 0;
while(x < 100){
console.log(x);
}
Infinite loop as the pivot variable/the loop continuation variable is not getting updated each iteration.
int sum = 0;
for(int i=1; i<=20; i++){
if(i%2==0)
sum+=i;
}
console.log(sum);
A for loop to print out the sum of all even numbers between 1 and 20.
SUM = 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + 20 = 110
int factorial = 1;
int i = 1;
while(i <= num){
factorial *= i;
i++;
}
A while loop to calculate the factorial of a variable named: num.
The error(s) in the following code:
for(var i=3; i<0; i++)
console.log(i);
Infinite loop since i will never be less than zero with it being incremented from 3 with each iteration.
Is this a valid for loop?
var i = 0
for(;i < 10; )
{
console.log("Hello")
}
Yes
What is the output of:
var sum = 0;
var i = 1;
while(i<=100){
sum = sum + i * i;
i++;
}
A while loop to calculate the sum of the squares of every number from 1 to 100.
The error(s) in the following code:
var i=-1;
while(i<0){
console.log(i);
i--;
}
What is...
var i=-1;
while(i<0){
console.log(i);
i++;
}