String Flashcards

1
Q

Change to uppercase:

A

.toUpperCase()

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

Change to lowercase:

A

.toLowerCase()

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

Remove leading & trailing whitespace from a string:

A

.trim()

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

Joins two or more strings:

A

.concat()

(ex.)let text1 = ‘Hello’;
let text2 = ‘World’;
let text3 = text1.concat(‘ ‘, text2);
console.log(text3);
»>’Hello World’

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

Replace string:

A

.replace()

Syntax: .replace(findValue, replaceValue)

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

Add a new item to the end

A

.push()

userName.push(“Aleesha”)
»>[“George”, “Alice”, “Rashid”, “Aleesha”]

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

Remove the last element of the array

A

.pop()

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

Remove the first element of the array

A

.shift()

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

Add new element at the beginning

A

.unshift()

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

By adding, removing, and inserting elements

A

.splice()

.splice(index, howMany, item1…, itemX);

let fruits =[“Banana”, “Orange”, “Apple”]
fruits.splice(2, 0, “Lemon”, “Kiwi”)
console.log(fruits)

> > > [“Banana”, “Orange”, “Lemon”, “Kiwi”, “Apple”]

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

Copies a given part of an array and returns that copied part as a new array

A

.slice()
array.slice(start, end)

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

Find a particular value in an array

A

.indexOf(searchValue, start)

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

Advanced array:
Reverse the order of the elements in an array

A

.reverse()

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

Advanced array:
Sort array in alphabetic order

A

.sort()

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