Worksheetsweb 2 JS
Total questions: 15
Worksheet time: 8mins
Name
Class
Date
1.
What is the correct syntax to declare a variable in JavaScript?
a)
int myVar;
b)
var myVar;
c)
let = myVar;
d)
dim myVar;
2.
How do you write a comment in JavaScript?
a)
/* comment */
b)
// comment
c)
# comment
d)
3.
What is the output of: 2 + '2' in JavaScript?
a)
4
b)
'4'
c)
NaN
d)
22
4.
Which keyword is used to define a constant in JavaScript?
a)
let
b)
var
c)
define
d)
const
5.
What does NaN stand for?
a)
Not a Number
b)
No assigned Name
c)
Negative and Null
d)
New assigned Name
6.
Which of the following comparisons is true?
a)
'5' == 5
b)
'5' === 5
c)
5 = '5'
d)
5 != 5
7.
How do you define a function in JavaScript?
a)
fun myFunc()
b)
function myFunc() {}
c)
function = myFunc()
d)
def myFunc()
8.
Which of these is a loop structure in JavaScript?
a)
for
b)
loop
c)
repeat
d)
foreach
9.
What is the correct way to check if `x` is not equal to `y`?
a)
x !=== y
b)
x <> y
c)
x >< y
d)
x != y
10.
Which symbol is used for strict equality in JavaScript?
a)
==
b)
=
c)
===
d)
!==
11.
How do you access the first element of an array named `arr`?
a)
arr.first()
b)
arr{0}
c)
arr(0)
d)
arr[0]
12.
How do you write an if statement in JavaScript?
a)
if x == 5 then
b)
if (x == 5)
c)
if x = 5
d)
if x === 5:
13.
Which operator is used for exponentiation in modern JavaScript?
a)
exp()
b)
**
c)
^
d)
^^
14.
Which of the following is NOT a valid JavaScript variable name?
a)
2value
b)
value2
c)
_value
d)
$name
15.
Which statement will correctly check if `a` is both greater than 0 and less than 10?
a)
a > 0 & a < 10
b)
a => 0 && a <= 10
c)
a > 0 && a < 10
d)
a > 0 || a < 10
100 %
