Question 1: What is JavaScript primarily used for?
a) Styling web pages
b) Adding interactivity to web pages
c) Creating web page layouts
d) Sending emails
Question 2: Which keyword is used to declare a variable in JavaScript?
a) var
b) int
c) string
d) variable
Question 3: How do you write a single-line comment in JavaScript?
a)
b) // This is a comment
c) /* This is a comment */
d) ’ This is a comment ’
Question 4: Which of the following is NOT a JavaScript data type?
a) Number
b) Boolean
c) String
d) Character
Question 5: How do you check if two variables have the same value and data type in JavaScript?
a) ==
b) ===
c) =
d) !=
Question 6: Which function is used to display a message in a popup dialog box in JavaScript?
a) alert()
b) console.log()
c) print()
d) prompt()
Question 7: How do you assign the value of variable x to variable y in JavaScript using an assignment operator?
a) x → y
b) x = y
c) x => y
d) x == y
Question 8: Which operator is used to combine two or more strings in JavaScript?
a) +
b) *
c) -
d) /
Question 9: How do you write a 'for' loop in JavaScript to execute a block of code 5 times?
a) for (i = 1; i <= 5; i++)
b) for (i = 0; i < 5; i++)
c) for (i = 0; i <= 5; i++)
d) for (i = 1; i < 5; i++)
Question 10: How do you check if two variables have different values in JavaScript using a comparison operator?
a) !=
b) ==
c) !==
d) ==!