BananaMaster

27 What is a loop and how the for loop works, and why infinite loops are dangerous (JS lessons)

If you forgot something, click to go to the lesson

Task 1.

Create a loop from 5 to 15. Output the loop variable to the console. Result: 5 6 7 8 9 10 11 12 13 14 15

Task 2.

Create a loop from 10 to 1. Output the numbers to the console in reverse order.

Task 3.

Create a loop from 1 to 5. Output: Hello 1, Hello 2, and so on.

Task 4.

Create a loop from 3 to 30 with a step of 3. Output the numbers to the console.

Task 5.

Create a loop from 1 to 20. Output only odd numbers to the console.

Task 6.

Create a loop from 10 to 1. Output each number multiplied by 2 to the console.

Task 7.

Create a loop from 0 to 20. Output only even numbers to the console.