1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
What is the keyword for finding a character at a particular location in a string? | charAt | charAt | |
In this string, what character is at index 2?— Don't include quotation marks in your answer. | "abcde" | c | •?c•? |
Find the 10th character in the string represented by txt and assign it to the variable char, which hasn't been declared beforehand. | let char = txt.charAt(9); | letchar=txt\.charAt\(9\); | |
Find the last character in the variable x's string and assign it to y, which hasn't been declared beforehand. | let y = x.charAt(x.length - 1); | lety=x\.charAt\(x\.length-1\); | |
Find the first character in a string represented by str and assign it to x, which hasn't been declared beforehand. | let x = str.charAt(0); | letx=str\.charAt\(0\); | |
Find the last character in a variable's string and assign it to a variable that hasn't been declared beforehand. Make up the variable names. | let x = str.charAt(str.length - 1); | let[a-z_$][a-zA-Z0-9_$]*=([a-z_$][a-zA-Z0-9_$]*)\.charAt\(\1\.length-1\); | |
Code the first line of an if statement that tests whether the 3rd character of a variable's string is a particular character. Make up the variable name and the string. | if (str.charAt(2) === "a") { | if\([a-z_$][a-zA-Z0-9_$]*\.charAt\(2\)===•.*•\){ | |
|
for (let i = 0; i < txt.length; i++) { txtArray.push(txt.charAt(i)); } |
for\(leti=0;i<([a-z_$][a-zA-Z0-9_$]*)\.length;i\+\+\){[\r\n][a-z_$][a-zA-Z0-9_$]*\.push\(\1\.charAt\(i\)\);[\r\n]} | |
|
|||
|