wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

IT tutor

Total questions: 18

Worksheet time: 15mins

Name
Class
Date
1.

Which modifier performs case-insensitive matching in regular expressions?

(a)  

2.

What does the regular expression pattern [0-9] match?

a)

Any letter from a to z

b)

Any digit from 0 to 9

c)

Any special character

d)

Any whitespace character

3.

Which metacharacter matches a digit in regular expressions?

(a)  

4.

What does the quantifier n+ match?

a)

Zero or more occurrences of n

b)

Exactly one occurrence of n

c)

At least one occurrence of n

d)

Zero or one occurrence of n

5.

JavaScript Methods and Objects

What does the test() method of RegExp return?

a)

The matched text

b)

The index of the match

c)

true or false

d)

A new string

6.

What will "Hello world!".repeat(2) return?

a)

"Hello world!Hello world!"

b)

"Hello world!2"

c)

"Hello world! Hello world!"

d)

An Error

e)

None of the Above

7.

What does the exec() method return when no match is found?

a)

false

b)

0

c)

null

d)

undefined

8.

Which variable declaration cannot be reassigned?

(a)  

9.

What does x <<= y do?

a)

Left shifts x by y bits and assigns result to x

b)

Right shifts x by y bits and assigns result to x

c)

Multiplies x by y

d)

Divides x by y

10.

Which assignment operator is equivalent to x = x + y?

(a)  

11.

Which of the following is true about Arrays In Javascript

a)

Can only store values of the same type

b)

Has fixed length

c)

Can store values of different types

d)

Cannot contain other arrays

12.

What is a multidimensional array?

a)

An array with multiple data types

b)

An array that contains other arrays

c)

An array with more than 100 elements

d)

An array with string keys

13.

Create a variable that cannot be changed called x and assign the value 5 to it

(a)  

14.

How do you write a single-line comment in JavaScript?

a)

/* comment */

b)

// comment

c)

<!-- comment -->

d)

# comment

15.

Which of these is NOT a valid JavaScript variable declaration?

a)

var x = 5;

b)

let x = 5;

c)

const x = 5;

d)

int x = 5;

16.

const num1 = 5;

const num2 = 6;

num1 = 10;

let total = num1 + num2;

a)

total should also be const

b)

price1 cannot be reassigned

c)

Missing semicolons after each line

d)

let should be var

17.

function showSlide(n) {

let slides = document.getElementsByClassName("mySlides");

for (let i = 0; i <= slides.length; i++) {

slides[i].style.display = "none";

}

}

a)

Missing Array.from() to convert HTMLCollection to an iterable array

b)

slides[i] will throw undefined in the last iteration due to i <= slides.length

c)

<= causes an off-by-one error

d)

display = "none" breaks accessibility

18.

Make an empty array called people

(a)