Front-end Web Development

Assignment for Week 9

  1. Create an HTML file. (Start with the HTML file in Assignment 1 as a basis. Feel free to skip the CSS creation/linking steps.)
  2. Create a JS file (a blank file with a .js extension).
  3. Add a <script> tag to the end of the <body> in the HTML file. Set its src attribute to the name of your JS file.
  4. In the JS file, declare a variable called createName and assign it a function:
    1. The function should accept two arguments, first and last.
    2. It should return a string which concatenates first, a space, and last.
  5. Declare another variable called askName and assign it another function:
    1. In the function, declare a variable called first, and assign it the result of the prompt DOM function call, which should ask for your first name.
    2. Declare a variable called last, and assign it the result of another prompt call, which should ask for your last name.
    3. Declare a variable called fullName, and assign it the result of calling the createName function we created above, passing in the first and last variables.
    4. Call the alert DOM function, using the fullName variable to tell the user what their full name is, e.g. Your name is John Smith!.
    5. No return command necessary.
  6. Call the askName function.

Extra credit:


More extra credit:


Solution