JavaScript Simplified / Chapter 52 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 function without a name is an ________ function. anonymous anonymous
Fill in the blank to code the first line of this anonymous function. ________________
  alert("Hello, World!");
}
function() { function\(\){
Code an anonymous function that returns the integer 12. function() {
  return 12;
}
function\(\){[\r\n]return12;[\r\n]}
In the following code, x is a ________. const x = function() { variable variable
Code the first line of an anonymous function assigned to a variable. Make up the variable name. Remember to use the preferred keyword, const. const anonFunc = function() { const[a-z_$][a-zA-Z0-9_$]*=function\(\){
Call an anonymous function using a variable. Make up the name of the variable. anonFunc(); [a-z_$][a-zA-Z0-9_$]*\(\);
A self-invoking anonymous function begins with an opening parenthesis, like this. Fill in the blank with 4 characters to complete it. (function() {
  alert("Hello, World!");
}____
) (); \)\(\);
Code a self-invoking function that displays an alert. Make up the alert string. (function() {
  alert("Hi");
})();
\(function\(\){[\r\n]alert\(•.*•\);[\r\n]}\)\(\);
  1. Assign an anonymous function to a variable. The function displays an alert.
  2. Call the function.
  3. Click the Result button (or, after revising, don't click, just wait).
  4. Wait a moment.
  5. If you've coded correctly, the alert will display.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 52 in the book.
  1. Code a self-invoking function. The function displays an alert.
  2. Click the Result button (or, after revising, don't click, just wait).
  3. Wait a moment.
  4. If you've coded correctly, the alert will display.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 52 in the book.