curriculum/challenges/english/blocks/quiz-javascript-strings/66edc31c44f1b9c1d5c5ebca.md
To pass the quiz, you must correctly answer at least 18 of the 20 questions below.
What is the return value for the includes() method?
If the substring is found within the string, the method returns the string. Otherwise, it returns undefined.
If the substring is found within the string, the method returns true. Otherwise, it returns an empty string.
If the substring is found within the string, the method returns the string. Otherwise, it returns null.
If the substring is found within the string, the method returns true. Otherwise, it returns false.
Which option demonstrates string interpolation?
"Hello, " + user + "!"
"Hello, $user!"
`Hello, {user}!`
`Hello, ${user}!`
Which of the following options is the newline character?
\newline
\new
\line
\n
Which of the following statements is correct about strings?
Strings are mutable and can be changed after they are created.
Strings are non primitive data types.
Strings can only be created using single quotes.
Strings are immutable.
What does ASCII stand for?
American Standard Code for Internet Information
Advanced Systematic Code for Internal Interchange
Automatic Standard Code for Internal Information
American Standard Code for Information Interchange
Which of the following methods extracts a portion of a string and returns a new string?
trim()
indexOf()
prompt()
slice()
What is the purpose of the prompt() method?
It displays a message in the console.
It displays an alert box with a message.
It displays a confirmation box with a message.
It displays a dialog box that waits for the user input.
Which of the following is the correct way to access the third character of a string?
const developer = "Jessica";
developer[3];
const developer = "Jessica";
developer[-1];
const developer = "Jessica";
developer[0];
const developer = "Jessica";
developer[2];
How can you obtain the ASCII value of the first character in the string "hello"?
"hello".charCode(0)
"hello".codeAt(0)
"hello".getCharIndex(0)
"hello".charCodeAt(0)
Which method can you use to obtain the character corresponding to an ASCII value?
toASCII()
toChar()
toCode()
fromCharCode()
Which of the following indexOf examples will log -1 to the console?
const organization = "freeCodeCamp";
console.log(organization.indexOf("e"));
const organization = "freeCodeCamp";
console.log(organization.indexOf("f"));
const organization = "freeCodeCamp";
console.log(organization.indexOf("C"));
const organization = "freeCodeCamp";
console.log(organization.indexOf("c"));
How can you check if the string "JavaScript" contains "Script"?
"JavaScript".has("Script")
"JavaScript".contains("Script")
"JavaScript".exists("Script")
"JavaScript".includes("Script")
Which of the following extracts the substring "Script" from the string "JavaScript"?
"JavaScript".find(5)
"JavaScript".extract(4)
"JavaScript".cut(5)
"JavaScript".slice(4)
How do you convert the string "JavaScript" to uppercase?
"JavaScript".upper()
"JavaScript".toUpper()
"JavaScript".convertUpper()
"JavaScript".toUpperCase()
How do you convert the string "JavaScript" to lowercase?
"JavaScript".lower()
"JavaScript".toLower()
"JavaScript".convertLower()
"JavaScript".toLowerCase()
Which of the following will replace "dogs" with "cats" in the string "I love dogs".
"I love dogs".slice("dogs", "cats")
"I love dogs".replaceWith("dogs", "cats")
"I love dogs".find("dogs", "cats")
"I love dogs".replace("dogs", "cats")
Which method is used to repeat a string a specified number of times?
times()
repeatTimes()
repeatNumber()
repeat()
What will the following code return: "abc".repeat(3)?
"abcabc"
"abcabcabcabc"
It will throw an error.
"abcabcabc"
Which method will remove whitespace from the beginning and end of a string?
strip()
removeWhitespace()
trimWhitespace()
trim()
Which of the following is the correct syntax for escaping quotes?
"She said, ?"Hello!?""
"She said, ."Hello!.""
"She said, //"Hello!//""
"She said, \"Hello!\""