This section covers the questions for the Strings in JavaScript to clear all your concepts.
Question 1
Which method is used to convert a string to an array of words based on space as a separator?
a. split()
b. toArray()
c. words()
d. split(' ')
Question 2
Which method is used to check if a string ends with a specific substring?
a. endsWith()
b. finishWith()
c. end()
d. terminate()
Question 3
Which method is used to check if a string starts with a specific substring?
a. startsWith()
b. beginsWith()
c. start()
d. initiate()
Question 4
Which method is used to extract a substring from a string based on its position and length?
a. substring()
b. slice()
c. splice()
d. substr()
Question 5
Which method is used to repeat a string a specified number of times in JavaScript?
a. repeat()
b. replicate()
c. duplicate()
d. copy()
Question 6
Which method is used to convert a string to a number in JavaScript?
a. toInt()
b. parseInt()
c. convertToNumber()
d. castToNumber()
Question 7
Which method is used to replace a specified substring with a new substring in a string?
a. replace()
b. swap()
c. substitute()
d. switch()
Question 8
Which method is used to remove whitespace from both ends of a string in JavaScript?
a. trim()
b. strip()
c. clean()
d. remove()
Question 9
Which method is used to find the index of the first occurrence of a specific character or substring in a string?
a. indexOf()
b. findIndex()
c. search()
d. locate()
Question 10
Which method is used to concatenate two or more strings in JavaScript?
a. append()
b. join()
c. concat()
d. add()
There are 10 questions to complete.