JavaScript Simplified / Chapter 53 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

Fill in the blank to complete the first line of an arrow function. const greet = () ___ { => =>
Fill in the blank to complete the first line of an arrow function. const greet = _______ { () => \(\)=>
Rewrite this code as the first line of an arrow function. const greet = function() { const greet = () => { constgreet=\(\)=>{
Code the first line of an arrow function that includes two parameters. Assign the function to the constant x. Make up the parameter names. const x = (a, b) => { constx=\([a-z_$][a-zA-Z0-9_$]*,[a-z_$][a-zA-Z0-9_$]*\)=>{
Code the first line of an arrow function that includes one parameter. Assign the function to the constant x. Code the shorthand version. Make up the parameter name. const x = a => { constx=[a-z_$][a-zA-Z0-9_$]*=>{
Code an arrow function with one parameter. The function displays the parameter value in an alert. Assign the function to a constant. Code the shorthand version. Make up everything. const x = a => alert(a); const[a-z_$][a-zA-Z0-9_$]*=([a-z_$][a-zA-Z0-9_$]*)=>alert\(\1\);
Code an arrow function that has one parameter. The function returns the parameter value. Don't code the shorthand version. Make up the constant and the parameter. const x = (a) => {
  return a;
}
const[a-z_$][a-zA-Z0-9_$]*=\(([a-z_$][a-zA-Z0-9_$]*)\)=>{[\r\n]return\1;[\r\n]}
Code an arrow function with one parameter that returns the parameter value. Assign the function to a constant. Code the concise version. Make up the constant and the parameter. const x = a => a; const[a-z_$][a-zA-Z0-9_$]*=([a-z_$][a-zA-Z0-9_$]*)=>\1;
  1. Code an arrow function that displays an alert, assigning the function to a constant.
  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, and alert will display.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 53 in the book.
  1. Code an arrow function with one parameter that's an integer, assigning the function to a constant.
  2. The function adds 1 to the parameter and returns the sum.
  3. Call the function, passing an integer as the argument—assigning the returned value to a variable.
  4. Display the value of the variable in an alert.
  5. Click the Result button (or, after revising, don't click, just wait).
  6. Wait a moment.
  7. If you've coded correctly, and alert will display the value.
  8. Dismiss the alert by clicking OK.
  9. For help with this code, see Chapter 53 in the book.