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

You can use a function anywhere you'd use a _______. variable variable
Call the function x() that calls the function y(). x(y()); x\(y\(\)\);
Fill in the blank to return a number rounded by the function roundNum(). function addNums(num1, num2) {
  let tot = num1 + num2;
  return __________;br}
roundNum(tot); roundNum\(tot\);
Code a function that does nothing but call another function. Make up all the names. function callAFunction {
  someFunction();
}
function[a-z_$][a-zA-Z0-9_$]*{[\r\n][a-z_$][a-zA-Z0-9_$]*\(\);[\r\n]}
Code a function call whose argument is another function call. Make up the names. doSomething(doSomethingElse()); [a-z_$][a-zA-Z0-9_$]*\([a-z_$][a-zA-Z0-9_$]*\(\)\);
Code an alert whose content is a function call. Make up the name of the function. alert(doSomething()); alert\([a-z_$][a-zA-Z0-9_$]*\(\)\);
Code a function that has two string parameters. It passes the same parameters as arguments to a second function that concatenates the two strings. The first function returns the result that comes back from the second function. All of this functionality requires just three lines of code. Make up the names. function lazyFunction(string1, string2) {
  return concat(string 1, string2);
}
function[a-z_$][a-zA-Z0-9_$]*\(([a-z_$][a-zA-Z0-9_$]*),([a-z_$][a-zA-Z0-9_$]*)\){[\r\n]return[a-z_$][a-zA-Z0-9_$]*\(\1,\2\);[\r\n]}
Code a function call whose argument is a second function call. The second function call passes one string as an argument. Make up the function names and the string. doSomething(doSomethingElse("Bogata")); [a-z_$][a-zA-Z0-9_$]*\([a-z_$][a-zA-Z0-9_$]*\(•.*•\)\);
  1. I've coded two functions. Leave my code intact.
  2. Code an alert. The content of the alert is a call to my first function.
  3. The argument of the call is my second function.
  4. Do the whole thing in one line of code.
  5. Click the Result button (or, after revising, don't click, just wait).
  6. If you've coded correctly, a prompt will display.
  7. If nothing happens, check to be sure there are three closing parentheses at the end of the statement.
  8. Enter a name in the prompt field.
  9. If you've coded correctly, the name will display in all uppercase.
  10. Dismiss the alert by clicking OK.
  11. For help with this code, see Chapter 50 in the book.
  1. I've coded a function that displays the first element of an array. Leave my code intact.
  2. Create an array.
  3. Call my function, passing your array name as an argument.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. Wait a moment.
  6. If you've coded correctly, an alert will display the first element of your array.
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 50 in the book.