Strings Flashcards

1
Q

Define a string called ‘statement’ with the text of - She said “How’s the family?”

A

var statement = “She said "How’s the family?"”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Set the ‘escapedNewLine’ variable to the string of a new line character.

A

var escapedNewLine = “\n”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Set the ‘escapedBackslash’ variable to the string of a backslash character.

A

var escapedBackslash = “\”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Set the ‘escapedTab’ variable to the string of a tab character.

A

var escapedTab = “\t”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What will the following console.log statement output?

var first_name = "Jim";
var last_name = "Hoskins";

console.log(first_name + last_name);

A

JimHoskins

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What will the following console.log statement output?

var myMultilineVar = “Line one\n” +
“Line two\n” +
“Line three”;

console.log(myMultilineVar);

A

on the first line “Line one”, the second “Line two”, and on the final line “Line three”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What will the following console.log statement output?

var first_name = "Jim";
var last_name = "Hoskins";

console.log(first_name + “ “ + last_name);

A

Jim Hoskins

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Backslash purpose

A

escapes the character

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

var quick = “The quick brown fox jumps over the lazy dog”;

Create a variable of ‘quickLength’, to assign the length of the string ‘quick’.

A

var quickLength = quick.length;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

var quick = “The quick brown fox jumps over the lazy dog”;

Create a variable of ‘indexOfBrown’, to find the index of the string of “brown” in the string ‘quick’.

A

var indexOfBrown = quick.indexOf(“brown”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

var quick = “The quick brown fox jumps over the lazy dog”;

Create a variable of ‘tenthCharacter’, to get the tenth character of the string ‘quick’.

A

var tenthCharacter = quick.charAt(9);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

var quick = “The quick brown fox jumps over the lazy dog”;

Create a variable of ‘wordBrown’, to extract the substring of “brown” from the string ‘quick’.

A

var wordBrown = quick.substr(10, 5);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

var quick = “The quick brown fox jumps over the lazy dog”;

Create a variable of ‘quickUpper’, to the uppercased version of the string ‘quick’.

A

var quickUpper = quick.toUpperCase();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

var quick = “The quick brown fox jumps over the lazy dog”;

Create a variable of ‘quickLower’, to the lowercased version of the string ‘quick’.

A

var quickLower = quick.toLowerCase();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

== vs. ===

A
== ---> value
=== ---> type and value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What will the following code evaluate to?

“a”.toLowerCase() === “A”.toLowerCase()

A

True

17
Q

What will the following code evaluate to?

“a” === “A”

A

False

18
Q

What will the following code evaluate to?

“A” < “a”

A

True

19
Q

What is the result of the following expression?

“Treehouse”.indexOf(‘h’);

A

4

20
Q

In JavaScript, what does a string represent?

A

an arbitrary sequence of characters of text

21
Q

What is the result of the following expression?

“Treehouse”.substr(3,4);

A

“ehou”

22
Q

What is the result of the following expression?

“Treehouse”.charAt(6);

A

“u”

23
Q

What character denotes the beginning of an escape character sequence?

A

\

24
Q

Why do we need to type \ in our string literals to represent the character \?

A

The \ represents the start of an escape sequence, so a literal \ must be represented as an escape sequence itself

25
Q

What will return the number of characters in the string, “Treehouse”?

A

“Treehouse”.length

26
Q

What operator is used to join two strings together in JavaScript?

A

+