JS Coding Questions Logo
JS Coding Questions
#370💼 Interview💻 Code

How do you create an array with some data

Advertisement

728x90

You can create an array with some data or an array with the same values using fill method.

javascript
1var newArray = new Array(5).fill("0");
2
3console.log(newArray); // ["0", "0", "0", "0", "0"]

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 28

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
370of476