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
The method for finding the number of characters in a string is the same as the method for finding the number of elements in an ______. | array | array | |
Fill in the blank. | let numberOfCharacters = someString_____; | .length | \.length |
Code the first line of an if statement checks if the number of characters in the string assigned to the variable story is greater than 500. | if (story.length > 500) { | if\(story\.length>500\){ | |
In a single line, display the number of characters in the string assigned to the variable sentence. | alert(sentence.length); | alert\(sentence\.length\); | |
|
for (let i = 0; i < paragraph.length; i++) { | for\(leti=0;i<[a-z_$][a-zA-Z0-9_$]*\.length;i\+\+\){ | |
Code an alert that concatenates the string "The number of characters is " with the number of characters in a string assigned to a variable. Make up the variable name. | alert("The number of characters is " + name.length); | alert\(•Thenumberofcharactersis•\+[a-z_$][a-zA-Z0-9_$]*\.length\); | |
Code an if statement. If the number of characters in a string assigned to a variable is more than 300, display an alert "Too much!" Make up the name of the variable. | if (post.length > 300) { alert("Too much!"); } |
if\([a-z_$][a-zA-Z0-9_$]*\.length>300\){[\r\n]alert\(•Toomuch!•\);[\r\n]} | |
If the length of str is less than 3, convert it to all-lowercase characters. | if (str.length < 3) { str.toLowerCase(); } |
if\(str\.length<3\){[\r\n]str\.toLowerCase\(\);[\r\n]} | |
|
|||
|