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
When the revised string is assigned to a new variable in the following code, what is the value of x, the original variable? Include quotation marks. | let x = "abc"; let y = x.replace("a", "z"); |
"abc" - When the revised string is assigned to a new variable, the original string is preserved in the original variable. | •?abc•? |
After these two statements execute, what is the value of x? Include quotation marks. | let x = "abc abc"; x = x.replace("a", "z"); |
"zbc abc" - The statement replaces only the first instance of "a". The revised string is assigned to the original variable, x. | •?zbcabc•? |
In the string represented by the variable reply, replace the first instance of "no" with "yes" and assign the revised string to revisedReply, which hasn't been declared beforehand. | let revisedReply = reply.replace("no", "yes"); | letrevisedReply=reply\.replace\(•no•,•yes•\); | |
In the string represented by the variable reply, replace all instances of "no" with "yes". Assign the revised string to the original variable. | reply = reply.replace(/no/g, "yes"); | reply=reply\.replace\(\/no\/g,•yes•\); | |
In the string represented by the variable reply, replace all instances of "one" with "1". Assign the revised string to newStr, which hasn't been declared beforehand. | let newStr = reply.replace(/one/g, "1"); | letnewStr=reply\.replace\(\/one\/g,•1•\); | |
In the string represented by a variable, replace the first instance of one string segment with another. Assign the revised string to the original variable. Make up everything. | str = str.replace("hee", "haw"); | ([a-z_$][a-zA-Z0-9_$]*)=\1\.replace\(•.*•,•.*•\); | |
In the string represented by a variable, replace all instances of one string with another. Assign the revised string to the original variable. Make up everything. | str = str.replace(/hee/g, "haw"); | ([a-z_$][a-zA-Z0-9_$]*)=\1\.replace\(\/.*\/g,•.*•\); | |
The string "Move up" has been assigned to the variable instruction. In a single statement and with the minimum amount of code, code an alert that displays instruction's string, but revised so it says "Move down" | alert(instruction.replace("up", "down")); | alert\(instruction\.replace\(•up•,•down•\)\); | |
|
|||
|