Which method returns the index of the first match of a substring?
A
indexOf() B
find() C
contains() D
match()
Analysis & Theory
`indexOf()` returns the position of the first occurrence of a substring.
What does the `slice(1, 4)` method do?
A
Deletes characters 1 to 4 B
Returns characters from index 1 to 4 (excluding 4) C
Replaces characters at index 1 to 4 D
Splits string into 4 pieces
Analysis & Theory
`slice(1, 4)` extracts characters from index 1 up to (but not including) index 4.
Which method joins two strings together?
A
add() B
merge() C
concat() D
append()
Analysis & Theory
`concat()` is used to combine two or more strings.
What is the result of `'hello'.toUpperCase()`?
A
Hello B
HELLO C
hello D
error
Analysis & Theory
`toUpperCase()` converts all characters to uppercase.
What will `'HELLO'.toLowerCase()` return?
A
HELLO B
Hello C
hello D
Error
Analysis & Theory
`toLowerCase()` returns the lowercase version of a string.
Which method removes whitespace from both ends of a string?
A
strip() B
trim() C
clean() D
slice()
Analysis & Theory
`trim()` removes whitespace from both the beginning and end of a string.
Which method returns a part of a string between two indexes?
A
cut() B
get() C
substring() D
replace()
Analysis & Theory
`substring(start, end)` extracts characters between two indexes.
Which method replaces part of a string with another value?
A
fix() B
replace() C
swap() D
edit()
Analysis & Theory
`replace()` replaces a matched value with a new one.
What does `'hello world'.includes('world')` return?
A
false B
true C
0 D
undefined
Analysis & Theory
`includes()` checks if the string contains a given value. It returns `true` or `false`.
Which method splits a string into an array?
A
break() B
explode() C
slice() D
split()
Analysis & Theory
`split()` breaks a string into an array of substrings.