JavaScript Simplified / Chapter 68 Exercises

  • Index of exercises
  • Email me

1

2

3

4

5

6

7

8

9

10

Congratulations. You've aced all the exercises for this chapter.


To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.


Are you ready to rate JavaScript Simplified? on Amazon?


Rate it on Amazon.

0,1,2,3,4,5,6,7,8,9

0

0

0

0

A field has been assigned to the variable fld. Fill in the blank to assign its value to the variable aVal. let aVal = ___________; fld.value fld\.value
A field has been assigned to the variable fld. Set its value to 0. fld.value = 0; fld\.value=0;
The id of a field is "name". Assign the field to the variable nameField. let nameField = document.querySelector("#name"); letnameField=document\.querySelector\(•#name•\);
The name field has been assigned to the variable nameField. Display the value of the field in an alert. alert(nameField.value); alert\(nameField\.value\);
The age field has been assigned to the variable ageField. Get the value of the field and assign it to a variable. Make up the name of the variable. let ageValue = ageField.value; let[a-z_$][a-zA-Z0-9_$]*=ageField\.value;
The city field has been assigned to the variable citF. Set the field's value to "Baku." citF.value = "Baku"; citF\.value=•Baku•;
A field's name is "address". In a single statement get the value of the field and assign it to a variable. Make up the name of the variable. let val = document.querySelector("[name = 'address']").value; let[a-z_$][a-zA-Z0-9_$]*=document\.querySelector\(•\[name=◘address◘\]•\)\.value;
The integer 144 has been assigned to the constant gross. In a single statement assign the number (using the constant) to the field whose id is "qty". document.querySelector("#qty").value = gross; document\.querySelector\(•#qty•\)\.value=gross;
  1. Click the HTML button to see the form I've coded. Notice that the "loris-type" field has a default value of "slow"
  2. Click the Result button. See the result of my HTML markup.
  3. Click the JS button. In a single statement display the value in an alert.
  4. Wait a moment.
  5. If you've coded correctly, an alert will display "slow".
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 68 in the book.
  1. Click the HTML button see the form I've coded. Notice that the "loris-type" field has a default value of "slow"
  2. Click the Result button. See the result of my HTML markup.
  3. Click the JS button.
  4. Code a statement that changes the value of the "loris-type" field to "fast".
  5. Click the Result button.
  6. If you've coded correctly, the value in the field will change to "fast";
  7. For help with this code, see Chapter 68 in the book.