Question
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
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, the correct results from this HTML page and script might look like this:
With Chrome, correct results from this HTML page and script might look likeStep 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