JavaScript Quiz Practice Set Level 1

Updated on ... 20th February 2024

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

Que: (13). 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();
                        
A.
B.
C.
D.

Que: (14). 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.
B.
C.
D.

Que: (15). 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.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

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

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

A.
B.
C.
D.

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

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

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

A.
B.
C.
D.

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

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

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

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

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

A.
B.
C.
D.

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

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

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

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

Que: (49). 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);
                        
A.
B.
C.
D.

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

A.
B.
C.
D.

Leave a comment