⊗jsPmLpAF 161 of 504 menu

Filling an array in JavaScript

You can fill arrays with data in a loop. To do this, use the push method:

let arr = []; for (let i = 1; i <= 5; i++) { arr.push(i); } console.log(arr); // shows [1, 2, 3, 4, 5]

Using a loop and the push method, fill an array with numbers from 1 to 10.

Using a loop and the push method, fill an array with 10 letters 'x'.

Given an array of numbers. Loop through it and write only positive numbers into the new array.

English
AzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItalianoქართულიҚазақLietuviųLatviešuМакедонскиMelayuNederlandsNorskPolskiPortuguêsRomânăРусскийSlovenčinaSlovenščinaShqipSvenskaKiswahiliTürkçeЎзбекOʻzbek
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline