String Methods Flashcards

1
Q

Find the position of the character h in the string txt and assign it to a variable named pos.

var txt = “abcdefghijklm”;

A

let pos = txt.indexOf(“h”);

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

Use the slice method to assign the word “bananas” to a variable named x.

var txt = “Go bananas!”;

A

let x = txt.slice(3 , 10);

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

Use the correct String method to replace the word “Hello” with the word “Welcome”.

var txt = “Hello World”;

A

let = txt.replace(“Hello”, Welcome”);

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

Convert the value of txt to upper case.

var txt = “Hello World”;

A

let = txt.toUpperCase();

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

Convert the value of txt to lower case.

var txt = “Hello World”;

A

let = txt.toLowerCase();

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