Filling an array in JavaScript
You can fill arrays with data in a loop.
To do this, use the push method:
javascriptlet arr = [];
for (let i = 1; i <= 5; i++) {
arr.push(i);
}
console.log(arr); // shows [1, 2, 3, 4, 5]
Задание 1
Using a loop and the push method,
fill an array with numbers from
1 to 10.
Задание 2
Using a loop and the push method,
fill an array with 10
letters 'x'.
Задание 3
Given an array of numbers. Loop through it and write only positive numbers into the new array.