JavaScript Multiple choices


Total available count: 50
Subject - JavaScript Frameworks
Subsubject - JavaScript

What is the correct way to write a JavaScript array?


 

 

 

 



A


Solution:-

An array is a special variable, which can hold more than one value at a time.

Storing courses in single variables could look like this:

var course1 = "HTML5";
var course2 = "CSS";
var course3 = "Javascript";

However, what if you want to loop through the courses and find a specific one? And what if you had not 3 courses, but 50?

The solution is an array!
An array can hold many values under a single name, and you can access the values by referring to an index number.

Creating an Array
Using an array literal is the easiest way to create a JavaScript Array.

Array Syntax is as follows:

var array_name = [item1, item2, item2,...];

Array Example is as follows:

var courses = ["HTML5", "CSS", "Javascript"];

 




Next 5 multiple choice(s)

1

How to insert a comment that has more than one line?

2

How can you add a comment in JavaScript?

3

How does a FOR loop start?

4

How does a WHILE loop start?

5

How to write an IF statement for executing some code if "i" is NOT equal to 5?

Comments