JavaScript Quiz Practice Set Level 1

Que: (1). What will be the output?

                            function output() {
    x = 33;
    console.log(x);
    var x;
}
output();
                        
C.
B.
A.
D.

Que: (2). What does the “NaN” value represent in JavaScript?

B.
C.
A.
D.

Que: (3). The external JavaScript file must contain the <script> tag.

B.
C.
A.
D.

Que: (4). Which of the following is not a comparison operator in JavaScript?

A.
B.
C.
D.

Que: (5). What is the correct JavaScript syntax to change the content of the HTML element below?

                            <p id="demo">This is a demonstration.</p>
                        
B.
C.
A.
D.

Que: (6). Which are the correct “if” statements to execute certain code if “x” is equal to 2?

A.
B.
C.
D.

Que: (7). How to write an IF statement in JavaScript?

C.
A.
B.
D.

Que: (8). How does a WHILE loop start?

B.
A.
C.
D.

Que: (9). What does the “this” keyword refer to in JavaScript?

B.
C.
A.
D.

Que: (10). How do you find the minimum of a and b using JavaScript?

A.
C.
B.
D.

Que: (11). How do you create a function in JavaScript?

B.
C.
A.
D.

Que: (12). What will be the output?

                            var x = 5;
var y = "5";
console.log(x + y);
                        
B.
C.
A.
D.

Que: (13). Which one is correct to write "Hello World" in an alert box?

B.
A.
C.
D.

Que: (14). What is the output of the following JavaScript code snippet?

                            // Which value will be logged to the console?
var x = 5;
function foo() {
    console.log(x);
    var x = 10;
}
foo();
                        
C.
B.
A.
D.

Que: (15). Which of the following keywords is used to define a variable in Javascript?

A.
C.
B.
D.

Que: (16). Inside which HTML element do we put the JavaScript?

B.
C.
A.
D.

Que: (17). How do you call a function named "myFunction"?

B.
C.
A.
D.

Que: (18). Which JavaScript label catches all the values, except for the ones specified?

A.
B.
C.
D.

Que: (19). How can a datatype be declared to be a constant type?

C.
A.
B.
D.

Que: (20). Which operator is used to assign a value to a variable?

A.
C.
B.
D.

Que: (21). Which of the following methods is used to access HTML elements using Javascript?

B.
C.
A.
D.

Que: (22). What is the correct syntax for a “for” loop in JavaScript?

A.
B.
C.
D.

Que: (23). Which of the following is not a loop in Javascript?

B.
C.
A.
D.

Que: (24). Which method is used to sorts the elements of an array?

C.
B.
A.
D.

Que: (25). Where is the correct place to insert a JavaScript?

A.
C.
B.
D.

Que: (26). How do you find the number with the highest value of x and y?

C.
B.
A.
D.

Que: (27). What will the code return? Boolean(2 < 5)

C.
A.
B.
D.

Que: (28). What will the following code return: Boolean(10 > 9)

A.
B.
C.
D.

Que: (29). How to insert a comment that has more than one line?

A.
C.
B.
D.

Que: (30). How does a FOR loop start?

B.
C.
A.
D.

Que: (31). How do you round the number 7.25, to the nearest integer?

C.
B.
A.
D.

Que: (32). Javascript is an _______ language?

A.
B.
C.
D.

Que: (33). What will be the output of the following code snippet?

                            <script type="text/javascript">
a = 5 + "9";
document.write(a);
</script>
                        
B.
C.
A.
D.

Que: (34). Which of the following is not a primitive data type in JavaScript?

A.
B.
C.
D.

Que: (35). What is the correct JavaScript syntax to change the content of the HTML element with id "demo" below?

A.
B.
C.
D.

Que: (36). What will be the output?

                            let x = 5+3+"3";
Console.log(x);
                        
B.
A.
C.
D.

Que: (37). How can you add a comment in a JavaScript?

B.
A.
C.
D.

Que: (38). What will be the output of the following code?

                            let a = 25;
let c = 25;
let b = new Number(25);
console.log(a == b);
console.log(a === b);
console.log(b == c);
                        
C.
A.
B.
D.

Que: (39). What will be the output?

                            var x;
console.log(x); 
x = 25;
                        
A.
C.
B.
D.

Que: (40). How to write an IF statement for executing some code if "i" is NOT equal to 5?

A.
B.
C.
D.

Que: (41). What does the “typeof” operator do in JavaScript?

B.
C.
A.
D.

Que: (42). Which event occurs when the user clicks on an HTML element?

B.
A.
C.
D.

Que: (43). JavaScript is a ___ -side programming language.

B.
A.
C.
D.

Que: (44). Javascript is a _____ language.

C.
B.
A.
D.

Que: (45). The "let" and " var" are known as:

A.
C.
B.
D.

Que: (46). What is the correct way to declare a variable in JavaScript?

B.
A.
C.
D.

Que: (47). What is the correct way to write a JavaScript array?

B.
A.
C.
D.

Que: (48). What does the following JavaScript code snippet do?

                            // What does this function return?
function factorial(n) {
    if (n === 0 || n === 1) {
        return 1;
    } else {
        return n * factorial(n - 1);
    }
}
                        
A.
C.
B.
D.

Que: (49). Which of the following will write the message “Hello World” in an alert box?

C.
B.
A.
D.

Que: (50). What will be the result of the following JavaScript code snippet?

                            // Which value will be alerted?
var x = 10;
function bar() {
    x = 20;
}
bar();
alert(x);
                        
A.
C.
B.
D.