JS STRING METHODS Flashcards

1
Q

Trim

A

.trim ()

Removes empty/white space before the start and after end of content in a string

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

Uppercase and Lowercase

A

text.toUpperCase()
text.toLowerCase()
(Changes the text to upper or lowercase)

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

Index Of

A

.indexOf (argument)
(Returns the index position)
// NOTE: indexOf will always return the first occurrence of the argument

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

Replace

A

.replace (argument)
(Replace content in a string)
// The first argument is the character(s) being selected. The second argument is the character(s) that is replacing the first.

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

Repeat

A

.repeat (argument)

Repeats content in a string

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

Slice

A

.slice (argument)
(Extracts part of string)
// First number/argument is the starting index. Second number/argument is the ending index (NOTE: Goes up to the second number/index, but does NOT include it in the slice).
//If a second number is NOT included, then the rest of the string will be included in the slice.
// When using negative numbers it starts from the end of the string (Starting at 1 NOT 0)

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