Question
2. Enter Script and Fix Error (10 points) Enter and test this script; it has two errors in it. For this program, you may cut
2. Enter Script and Fix Error (10 points) Enter and test this script; it has two errors in it. For this program, you may cut and paste the lines into your source editor. By the way, be very careful when cutting and pasting source code, the double quote character () is often mangled. Note this code uses the single quote (), which is usual less of an issue. Hints: (1) Turn on your browsers console to see the error messages, and (2) there are two errors. Try looking for spelling errors and missing characters.
3. Write Your Own Script #1 (10 points) Using the above scripts (which are HTML pages) as models, write a script that stores 55 is a variable called age and the increments the age by 1 using the ++ operator. Finally, the script should output the new age. Both of our textbooks touch on the ++ operator and you can also learn more about it using Google/Bing. With Chrome, a correct output from this HTML page and script might look like: 4. Write Your Own Script #2 (10 points) Using the above scripts as models and the JavaScript prompt method, write a simple script that will prompt the user for a number and then reply back to the user that the number is or is not equal to 2. You will need to define a variable with var (the name of the variable is up to you), prompt to get a value into the variable, and then use an if statement to see if the variable is equal to 2. Finally, you can use the alert method to output equal 2 or not equal 2. Some Hints: a. The optional texts chapter 9 covers the prompt method. There are also lots of prompt examples available via Google/Bing. b. The if statement is covered in our main textbook, in the optional text, and in many examples available via Google/Bing. c. If you have never programmed before, this problem might be rather intense. If you run out of time, turn in what you have started for partial credit. In about 2-3 weeks, you will look back and see this problem as trivial. Honest! With Chrome, correct results from this HTML page and script might look like:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started