Input Name and Age

Create a project 04-InputNameAge that gets the users name and age, and then prints a personal message to them telling them how old they'll be next year.

Instructions

  1. After logging into repl.it, click "+ new repl", and select "HTML, CSS, JS" for your environment. A random name will be given to your project, but you should change it to this: 04-InputNameAge

  2. We're only going to use the HTML file index.html for this exercise, and write our JavaScript in the body of that file (between the <body> and </body> tags). Remember to put a <script> tag before your code, and a </script> tag after your code.

  3. Have the user enter their name using the prompt() function. Also, have the user enter their age.

  4. Note that the prompt() function has the user enter a string value. This is fine for something like somebody's name, but if you want to use the value that's entered as a number, you'll need to convert it using parseInt() or parseFloat().

  5. Use the document.write() function to print out a personalized message to the user that looks something like this:

     Hello, Richard!
     This year you are 60 years old.
     Next year you will be 61!

    Note that if you want to print text on separate lines, you'll need to use JavaScript to also send a <br /> tag at the end of every line you want displayed.

Finishing Up

Once your program is working correctly, use your mouse to click-drag over the URL address for your project at the top of the browser window. Copy that link, and give that copied link to the instructor using the procedure given in class.