PrepAway - Latest Free Exam Questions & Answers

Which choice demonstrates the correct syntax for an array in JavaScript?

You want to display a series of elements. Which choice demonstrates the correct syntax for an
array in JavaScript?

PrepAway - Latest Free Exam Questions & Answers

A.
var myArray = Array(1,2,3,4,5)
for (var i = 0; i < myArray.[i]; i++ ){
document.write( myArray[i] + “
” );

B.
var myArray = new Array(1,2,3,4,5)
for (var i = 0; i < myArray.length ; i++ ){
document.write( myArray[i] + “
” );

C.
var myArray = new Array(1,2,3,4,5)
for (var i = 1; i < myArray.length; i– ){
document.write( myArray.length + “
” );

D.
var myArray = Array(1,2,3,4,5)
for (var i = 1; i < myArray.[i] ; i– ){
document.write( myArray[i] + “
” );

Explanation:

PrepAway - Latest Free Exam Questions & Answers

Leave a Reply