Use a loop to output a column of
numbers from 1
to 100
.
Use a loop to output a column of
numbers from 100
to 1
.
Use a loop to output a column of
even numbers from 1
to 100
.
Fill the array with 10
x using a loop.
Fill the array with numbers from
1
to 10
using a loop.
Given an array of numbers. Using the
loop, output only those elements of
the array that are greater than zero
and less than 10
.
Given an array of numbers. Use a loop
to check that it has an element
with value 5
.
Given an array of numbers. Use a loop to find the sum of the elements of this array.
Given an array of numbers. Use a loop to find the sum of the squares of the array elements.
Given an array of numbers. Find the arithmetic mean of its elements.
Write a script that will find the factorial of a number. Factorial is the product of all integers from one to a given number.
Fill the array with numbers from
10
to 1
using a loop.
Given an array of numbers. Numbers can be positive or negative. Find the sum of positive array elements.
Given an array of numbers, for example:
let arr = [10, 20, 30, 50, 235, 3000];
Print only those numbers from the array
that start with 1
, 2
or 5
.
Given an array of numbers. Print the elements of this array in reverse order.
Given an array of numbers. Use a loop to display all elements whose value matches their index number in the array.
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.
Given an array of numbers. Using the loop
for
and the function document.write
print each element of the array in
a separate paragraph.
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.
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
.
Given the following object with employees and their salaries:
let obj = {
employee1: 100,
employee2: 200,
employee3: 300,
employee4: 400,
employee5: 500,
employee6: 600,
employee7: 700,
};
Increase the salary of each
employee by 10%
.
Modify the previous task so that the
salary increases only for those employees
whose salary is less than or
equal to 400
.
Given the following arrays:
let 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.
Given the following object:
let 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.
Given the following object:
let obj = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5};
Write the object keys to one array and the values to another.
Given the following object:
let 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:
[
125,
225,
128,
145,
281,
];
Given the following array:
let arr = ['a', 'b', 'c', 'd', 'e'];
Create the following object from this array:
{1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e'};
Given the following array:
let arr = ['a', 'b', 'c', 'd', 'e'];
Create the following object from this array:
{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5};