Basic Flashcards

1
Q

How does a concatenation look like?

A

val = firstName + ‘ ‘ + lastName;

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

How can you return ‘Brad Lois’ by append?

A

val = ‘Brad ‘

val += ‘Lois’;

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

How does look escaping?

A
val = 'That\'s something you shouldn\'t have done'
val = "That's something you shouldn't have done"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can I get the length of a string?

A

val = firstName.length;

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

How does look .concat?

A

val = firstName.concat(‘ ‘, lastName);

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

How can you put a lower case or upper case to a variable?

A
val = firstName.toUpperCase();
val = firstName.toLowerCase();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is indexOf() for?

and what is lastIndexOf()?

A

It’s to look for a certain item within a string and return the position of it as if looking for an array and returning its position.

lastIndexOf() it’s the same but it starts from the end of the string.

tip: in indexOf() and lastIndexOf() you should enter letters so it returns the position in number.

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

what is charAt used for?

A

charAt is used in order to look for a character within an argument you should enter the value as a number so it returns the letter that is in that position.

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

formula to get the last character using charAt?

A

val = firstName.charAt(firstName.length - 1)

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

How .substring() works?

A

Gives the string from position x to position x, (look reference on vs)

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

What is a .substring()? what it’s the formula?

A

a substring is a contiguous sequence of characters within a string. For instance, “the best of” is a substring of “It was the best of times”.

val = firstName.substring(0, 4);

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

how it’s used.slice() and how it’s different from .substring()? what it’s the formula?

A

It’s mostly used to pull things out of arrays, it’s very similar to substring.

the difference between slice and substring, it’s that you can put a negative number in it so it looks for it backward to frontwards.

val = tags.split(“,”);

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

how does .split() works? what it’s the formula?

A

Can split a string into an array base on the separator, the separator it’s whatever it’s within the parenthesis and it should be within a string “”.

val = str.split(" ");
val = tags.split(",");
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does replace and what it’s the formula?

A

with this you can replace something inside the string

val = str.replace(‘Brad’, ‘Jack’);

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

What’s the function of .includes? what it’s the formula?

A

It will return true or false if the parameter within it, it’s there or not, if it’s there return true if not false.

val = str.includes(‘Hello’);

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