• Courses
  • Tutorials
  • Practice
Switch to Dark Mode

JavaScript String - School Programming

Here we will cover the Quiz related to JavaScript String to clear all your concept.

Last Updated : Feb 22, 2025
Discuss
Comments

Question 1

Which of the following is a valid way to declare a string variable in JavaScript?

b. string name = 'John';

  • A

    a. var name = 'John';

  • B

    b. const name = 'John';

  • C

    c. let name = 'John';

  • D

    d. All of the above

Question 2

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

  • A

    a. append()

  • B

    b. join()

  • C

    c. concat()

  • D

    d. add()

Question 3

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 4

Which method is used to convert a string to uppercase letters in JavaScript?

  • A

    a. toLowerCase()

  • B

    b. upperCase()

  • C

    c. toUpperCase()

  • D

    d. upper()

Question 5

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 6

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 7

Which method is used to split a string into an array of substrings based on a specified separator?

  • A

    a. slice()

  • B

    b. split()

  • C

    c. divide()

  • D

    d. break()

Question 8

Which method is used to return the length of a string in JavaScript?

  • A

    a. length()

  • B

    b. size()

  • C

    c. count()

  • D

    d. getSize()

Question 9

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 10

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()

There are 14 questions to complete.

Take a part in the ongoing discussion