Chapter 10 Review

  1. Create a function declaration named sumPair that returns the sum of the two arguments that are passed into it.
  2. Initialize two variables and pass them to sumPair. Print the result.
  3. Create a function expression named sumTriple that returns the sum of the three arguments that are pass to it.
  4. Initialize three variables and pass them to sumTriple. Print the result.
  5. Create an arrow function named sumQuad that returns the sum of the four arguments that are passed into it.
  6. Initialize four variables and pass them to sumQuad. Print the result.
  7. Create a function declaration named sumAll that returns the sum of the values in its arguments property.
  8. Call sumAll, passing to it 5 numbers. Print the result.
  9. Create a function named max that allows any number of arguments and returns the maximum value of the arguments that are passed into it. Set the first parameter’s default value to undefined, so that if no arguments are passed to max, undefined is returned.
  10. Call max with no arguments. Print the result.
  11. Call max with 3 arguments. Print the result.
  12. Declare an array named values that holds the values 2,4,6,8, and 10. Call max using the spread operator on values.
  13. Declare a function named min that allows any number of arguments and returns the minimum value of the arguments that are passed into it. Use a rest parameter to hold the values that are passed into the method. Return undefined if no arguments are passed to the function.
  14. Call min with no arguments. Print the result.
  15. Call min with 3 arguments. Print the result.

© 2020, Eric. All rights reserved.