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

Any name that is legal for a _________ is legal for a function. variable variable
This is the first line of the function code. Write the statement that calls the function. function doSomething() { doSomething(); doSomething\(\);
Code the first line of a function displayAlert() function displayAlert() { functiondisplayAlert\(\){
Code a function named askName() that prompts the user to "Enter name" and assigns the answer to userName, which hasn't been declared beforehand. function askName() {
  let userName = prompt("Enter name");
}
functionaskName\(\){[\r\n]letuserName=prompt\(•Entername•\);[\r\n]}
Code the first line of a function. Make up the name of the function. function findsPrice() { function[a-z_$][a-zA-Z0-9_$]*\(\){
Code a function that displays an alert with your first name as the message. Make up the name of the function. function say() {
  alert("Mark");
}
function[a-z_$][a-zA-Z0-9_$]*\(\){[\r\n]alert\(•.*•\);[\r\n]}
Code a function that converts string1 to all-uppercase and assigns it to string2. Make up the name of the function. function capIt() {
  let string2 = string1.toUpperCase();
}
function[a-z_$][a-zA-Z0-9_$]*\(\){[\r\n]letstring2=string1\.toUpperCase\(\);[\r\n]}
Code a function that calls another function. Make up the names of the functions. function func1() {
  func2();
}
function[a-z_$][a-zA-Z0-9_$]*\(\){[\r\n][a-z_$][a-zA-Z0-9_$]*\(\);[\r\n]}
  1. Code a function that 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 47 in the book.
  1. Code a function that displays a prompt, "Enter name" and then displays the name in an alert.
  2. Call the function.
  3. Enter a name in the prompt field.
  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 name.
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 47 in the book.