BananaMaster

41.1 - How for works and what it is ( JS lessons )

If you forgot something — click to go to the lesson.

Task 1.

Create a button. On click, print the numbers from 1 to 5 to the console.

Task 2.

Create an input type="number", a button and a div. On click, print into the div the numbers from 1 to the entered number.

Task 3.

Create a button and a div. On click, print into the div all odd numbers from 1 to 9.

Task 4.

Create two input type="number", a button and a div. In the first input the user enters the starting number, in the second — the ending number. On button click, using a loop, print into the div all numbers from the first entered number to the second, inclusive.

Task 5.

Create a button and a div on the page. Make a loop from 1 to 5. On click, print into the div buttons with the text: Button 1, Button 2, Button 3...

Task 6.

Using nested loops, draw and render into HTML:

            11111
22222
33333
44444
55555

The code must run only on button click.

Task 7.

Create an input. The user enters a number.

Using nested loops, draw and render into HTML:

If the user entered 4:

The loop runs from 1 to the entered number.

1
22
333
4444

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

The code must run only on button click.