String Manipulation in JavaScript Flashcards

1
Q

.length()

A

returns count of total number of characters

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

.charAt()

A

returns a char at the given index number

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

.includes()

A

returns True if the string includes a certain character/word, False if it doesnt

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

.indexOf()

A

displays index of the first occurence of the element. if the element is not in a string, it will return -1

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

.replace()

A

returns a string replacing all the old char or CharSequence to newchar or ChrSequence. The original string will remain unchanged

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

.search()

A

seraches a string for a specified value, and returns the position of the match

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

.slice()

A

str.slice(2,5)

will print out up to index 5 but not including it (“I love Javascript”//”lov”)

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

.split()

A

splits a string into an array of substrings, and returns the new array. Delimeter can be a space or any character and JS will look for that inside the string and split:

		let str = "I love Javascript"
		let a = str.split(" ")
		console.log(a)// [ 'I', 'love', 'Javascript' ]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

.toUpperCase()

A

returns the calling string value converted to upper case

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

.concat()

A

adds the strings

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

.join()

A

transforms array to a string, it is opposite of split()

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

.trim()

A

removes whitespaces from the both sides of the string

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