Understanding Core JavaScript Fundamentals - How Do You Get the Length for an Array, and How Can You Create an Empty Array of Fixed Length?

Tell us what’s happening:

const emptyArray = new Array(5);
console.log(emptyArray.length); // 5
console.log(emptyArray); // [,]

shouldn’t that be

console.log(emptyArray); //[ <5 empty items> ]

? Seems to be a mismatch between content and quiz questions

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15

Challenge Information:

Understanding Core JavaScript Fundamentals - How Do You Get the Length for an Array, and How Can You Create an Empty Array of Fixed Length?

1 Like

how an empty element in an array is shown depends by environment

the one I use is showing a different one, it shows [empty x 5]

there isn’t a standard way to show an empty item, so they are all correct

probably this one is not correct: [,,,,], it needs 5 commas to show an array of length 5 with empty things inside