JavaScript Strings

Last Updated :
Discuss
Comments

Question 1

Which method is used to convert a string to an array of words based on space as a separator?

  • A

    a. split()

  • B

    b. toArray()

  • C

    c. words()

  • D

    d. split(' ')

Question 2

Which method is used to check if a string ends with a specific substring?

  • A

    a. endsWith()

  • B

    b. finishWith()

  • C

    c. end()

  • D

    d. terminate()

Question 3

Which method is used to check if a string starts with a specific substring?

  • A

    a. startsWith()

  • B

    b. beginsWith()

  • C

    c. start()

  • D

    d. initiate()

Question 4

Which method is used to extract a substring from a string based on its position and length?

  • A

    a. substring()

  • B

    b. slice()

  • C

    c. splice()

  • D

    d. substr()

Question 5

Which method is used to repeat a string a specified number of times in JavaScript?

  • A

    a. repeat()

  • B

    b. replicate()

  • C

    c. duplicate()

  • D

    d. copy()

Question 6

Which method is used to convert a string to a number in JavaScript?

  • A

    a. toInt()

  • B

    b. parseInt()

  • C

    c. convertToNumber()

  • D

    d. castToNumber()

Question 7

Which method is used to replace a specified substring with a new substring in a string?

  • A

    a. replace()

  • B

    b. swap()

  • C

    c. substitute()

  • D

    d. switch()

Question 8

Which method is used to remove whitespace from both ends of a string in JavaScript?

  • A

    a. trim()

  • B

    b. strip()

  • C

    c. clean()

  • D

    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

    a. indexOf()

  • B

    b. findIndex()

  • C

    c. search()

  • D

    d. locate()

Question 10

Which method is used to concatenate two or more strings in JavaScript?

  • A

    a. append()

  • B

    b. join()

  • C

    c. concat()

  • D

    d. add()

There are 10 questions to complete.

Take a part in the ongoing discussion