For Loops!
While Loops!
What's the error??
100

The first statement inside the parenthesis of the for loop. (ie. for(    ;    ;   ))

What is the initial value for the loop variable?

100

What is 1 a placeholder for?

1

while( 2 ){

     3

}

4

The location of the loop variable initialization:


100

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

100

The second statement inside the parenthesis of the for loop. (ie. for(    ;    ;   ))

What is the loop condition?

100

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( ___ ))

100

Fix the error(s) in the following code:

While(i<100);

     console.log(i);


var i=0;

while(i<100)

{

    console.log(i); 

    i++;

100

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?)

100

What is 3 a placeholder for?


1

while( 2 ){

    3

}

4

The location of the loop variable action (increment/decrement).

100

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

}___

200

The output of:

for(int i=1;i<=10;i++)

{

      console.log(i + " ");

}

 "1 2 3 4 5 6 7 8 9 10"

200

What is the output of:

int j = 3;

while ( j <= 11)

{

    console.log(j + “ ”);

    j+=2;

}

"3 5 7 9 11"

200

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;

}

300

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)

300

What is the output of:

int n=0, count=0;            

while(n<8) {                       

   count += n;        

   n+=2;               

}                  

console.log( count );

12

300

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.

400

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

400

int factorial = 1;

int i = 1;

while(i <= num){

       factorial *= i;

        i++;

}      


A while loop to calculate the factorial of a variable named: num.

400

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.

500

Is this a valid for loop?

var i = 0

for(;i < 10; )

{

     console.log("Hello")

}

Yes

500

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.

500

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

}