Loops practice in JavaScript

Задание 1

Use a loop to output a column of numbers from 1 to 100.

Задание 2

Use a loop to output a column of numbers from 100 to 1.

Задание 3

Use a loop to output a column of even numbers from 1 to 100.

Задание 4

Fill the array with 10 x using a loop.

Задание 5

Fill the array with numbers from 1 to 10 using a loop.

Задание 6

Given an array of numbers. Using the loop, output only those elements of the array that are greater than zero and less than 10.

Задание 7

Given an array of numbers. Use a loop to check that it has an element with value 5.

Задание 8

Given an array of numbers. Use a loop to find the sum of the elements of this array.

Задание 9

Given an array of numbers. Use a loop to find the sum of the squares of the array elements.

Задание 10

Given an array of numbers. Find the arithmetic mean of its elements.

Задание 11

Write a script that will find the factorial of a number. Factorial is the product of all integers from one to a given number.

Задание 12

Fill the array with numbers from 10 to 1 using a loop.

Задание 13

Given an array of numbers. Numbers can be positive or negative. Find the sum of positive array elements.

Задание 14

Given an array of numbers, for example:

javascriptlet arr = [10, 20, 30, 50, 235, 3000];

Print only those numbers from the array that start with 1, 2 or 5.

Задание 15

Given an array of numbers. Print the elements of this array in reverse order.

Задание 16

Given an array of numbers. Use a loop to display all elements whose value matches their index number in the array.

Задание 17

Given an array of numbers. Using the loop for and the function document.write print each element of the array in a new line. Use the br tag for this.

Задание 18

Given an array of numbers. Using the loop for and the function document.write print each element of the array in a separate paragraph.

Задание 19

Make an array of days of the week. Use the loop for to output all the days of the week, and output the weekends in bold.

Задание 20

Make an array of days of the week. Use the loop for to print all the days of the week, and print the current day in italics. The number of the current day should be stored in the variable day.

Задание 21

Given the following object with employees and their salaries:

javascriptlet obj = {
  employee1: 100,
  employee2: 200,
  employee3: 300,
  employee4: 400,
  employee5: 500,
  employee6: 600,
  employee7: 700,
};

Increase the salary of each employee by 10%.

Задание 22

Modify the previous task so that the salary increases only for those employees whose salary is less than or equal to 400.

Задание 23

Given the following arrays:

javascriptlet arr1 = [1, 2, 3, 4, 5];
let arr2 = [6, 7, 8, 9, 10];

Using these arrays, create a new object, making its keys from the elements of the first array and its values from the elements of the second.

Задание 24

Given the following object:

javascriptlet obj = {1: 6, 2: 7, 3: 8, 4: 9, 5: 10};

Find the sum of the object keys and divide it by the sum of the object values.

Задание 25

Given the following object:

javascriptlet obj = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5};

Write the object keys to one array and the values to another.

Задание 26

Given the following object:

javascriptlet obj = {
  1: 125,
  2: 225,
  3: 128,
  4: 356,
  5: 145,
  6: 281,
  7: 452,
};

Write to the new array the elements whose value starts with the number 1 or the number 2. That is, you will end up with an array like this:

javascript[
  125,
  225,
  128,
  145,
  281,
];
Задание 27

Given the following array:

javascriptlet arr = ['a', 'b', 'c', 'd', 'e'];

Create the following object from this array:

javascript{1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e'};
Задание 28

Given the following array:

javascriptlet arr = ['a', 'b', 'c', 'd', 'e'];

Create the following object from this array:

javascript{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5};