wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Intro - Strings in JavaScript (Quiz Review)

Total questions: 16

Worksheet time: 3mins

Name
Class
Date
1.

What is returned?

var str = "Turkey";

return str.length;

(a)  

2.

What is returned?

var str = "Turkey";

return str.indexOf("key");

(a)  

3.

What is returned?

var str = "Turkey";

return str.indexOf("ham");

(a)  

4.

What is returned?

var str = "Turkey";

return str.subtring(1,4);

(a)  

5.

What is returned?

var str = "Turkey";

var str2 = "Bacon"

return (str.length > str2.length);

a)

6

b)

5

c)

True

d)

False

6.

What is returned?

var str = "New Jersey";

return (str.substring(4, str.length));

(a)  

7.

What is returned?

var str = "New Jersey";

return (str.substring(str.length-1, str.length));

(a)  

8.

What is returned?

var str = "New Jersey";

return (str.length + str.indexOf("ew"));

(a)  

9.

What is returned?

var str = "New Jersey";

var x = str.substring(0,1);

var y = str.substring(4,5);

return x+y;

(a)  

10.

What is returned?

var str = "Apple";

var str2 = "Orange";

return (str.length == str2.length);

a)

5

b)

6

c)

False

d)

True

11.

int x = "quarantine".indexOf("a");


What is the value of x?

a)

4

b)

3

c)

2

d)

This code does not compile.

e)

StringIndexOutOfBoundsException

12.

String s = "good job".substring(3, 9);


What is the value of s?

a)

"d job"

b)

"od job"

c)

"d jo"

d)

"od jo"

e)

StringIndexOutOfBoundsException

13.

String s = "elephant".substring(2, 5);


What is the value of s?

a)

"eph"

b)

"ele"

c)

"lep"

d)

"phant"

e)

StringIndexOutOfBoundsException

14.

What is returned?

var str = "Cat";

var str2 = "Dog";

return (str.length == str2.length);

a)

3

b)

False

c)

StringIndexOutOfBoundsException

d)

True

15.

Which of the following string methods can be used to check if a string value contains an uppercase Z?

a)

indexOf

b)

substring

c)

length

d)

toUpperCase

16.

Which of the following string methods can be used to extract a piece of a string and save it to a separate location?

a)

indexOf

b)

length

c)

substring

d)

toUpperCase