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

The variables in a function definition that receive the data passed to them by the calling code are called _________. parameters parameters
The rules for naming parameters are the same as the rules for naming ______. variables variables
Code a call to the function displayAlert() that passes the argument "Hello world" displayAlert("Hello world"); displayAlert\(•Helloworld•\);
Code the first line of a function named concat(). It has 3 parameters—the first three letters of the alphabet—all strings. function concat("a", "b", "c") { functionconcat\(•a•,•b•,•c•\){
Code a function call that has a variable, a string, and a number as arguments. Make up the name of the function and the arguments. makeAddress(city, "Texas", 24); [a-z_$][a-zA-Z0-9_$]*\([a-z_$][a-zA-Z0-9_$]*,•.*,[-]?(?:[.]\d+|\d+(?:[.]\d*)?)\);
Code the first line of a function that has 2 parameters. Make up the name of the function and the parameters. function combineNames(firstName, lastName) { function[a-z_$][a-zA-Z0-9_$]*\([a-z_$][a-zA-Z0-9_$]*,[a-z_$][a-zA-Z0-9_$]*\){
Code a function that has 2 parameters. Concatenate them and assign the result to a variable that hasn't been declared beforehand. Make up all the names. function concat(string1, string2) {
  let combo = string1 + string2;
}
function[a-z_$][a-zA-Z0-9_$]*\(([a-z_$][a-zA-Z0-9_$]*),([a-z_$][a-zA-Z0-9_$]*)\){[\r\n]letcombo=\1\+\2;[\r\n]}
Code a function that has three number parameters. Multiply them. Assign them to a variable that hasn't been declared beforehand. Make up all the names. function mult(a, b, c) {
  let num = a * b * c;
}
function[a-z_$][a-zA-Z0-9_$]*\(([a-z_$][a-zA-Z0-9_$]*),([a-z_$][a-zA-Z0-9_$]*),([a-z_$][a-zA-Z0-9_$]*)\){[\r\n]let[a-z_$][a-zA-Z0-9_$]*=\1\*\2\*\3;[\r\n]}
  1. I've coded a call to a function that displays an alert. Leave my code intact.
  2. Code 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 48 in the book.
  1. Code a function with 2 number parameters.
  2. The function sums the two parameters and assigns the sum to a variable.
  3. The function displays an alert concatenating "The sum is " with the variable.
  4. Call the function
  5. Click the Result button (or, after revising, don't click, just wait).
  6. Wait a moment.
  7. If you've coded correctly, an alert will display the message.
  8. Dismiss the alert by clicking OK.
  9. For help with this code, see Chapter 48 in the book.