BananaMaster

37 - Nested for loops, rendering into HTML | br tag (JS lessons)

If you forgot something, click to go to the lesson

Task 1.

Using nested loops, draw and render into HTML:

                *****1
*****2
*****3
*****4

The outer loop runs 4 times. The inner loop runs 5 times.

The code must run only on button click.

Task 2.

Using nested loops, draw and render into HTML:

                1 2 3 4 5 -1
1 2 3 4 5 -2
1 2 3 4 5 -3
1 2 3 4 5 -4

The outer loop runs 4 times. The inner loop runs 5 times.

The code must run only on button click.

Task 3.

Using nested loops, draw and render into HTML:

                [ 1 2 3 4 5 ]-1
[ 1 2 3 4 5 ]-2
[ 1 2 3 4 5 ]-3
[ 1 2 3 4 5 ]-4

The outer loop runs 4 times. The inner loop runs 5 times.

The code must run only on button click.

Task 4.

Using nested loops, draw and render into HTML:

                99999
88888
77777
66666

The outer loop goes from 9 down to 6. The inner loop runs 5 times.

The code must run only on button click.

Task 5.

Using nested loops, draw and render into HTML:

                XXXXX
YYYYY
ZZZZZ

The outer loop runs 3 times. The inner loop runs 5 times.

The code must run only on button click.

Task 6.

Using nested loops, draw and render into HTML:

                1
12
123
1234
12345

The outer loop runs 5 times. The inner loop depends on the outer loop.

The code must run only on button click.

Task 7.

Create an input. The user must enter a number.

Using nested loops, draw and render into HTML:

If the user entered 3:

                1
12
123

The number of outer loop iterations depends on the input value.

The code must run only on button click.