Question
Create a 3.html and a3.js files and link the two files. Your HTML page must not have any validation errors and should have a descriptive
Create a 3.html and a3.js files and link the two files. Your HTML page must not have any validation errors and should have a descriptive title, descriptive ids, and proper style.
Part 1: Valid Positive Number
Write the isValidPositiveNumber function
Parameters: One string parameter that we will validate
Operation: Check if the string will successfully convert to a valid positive number. It must not convert into NaN and after conversion, it's value must be greater than 0.
Returns: true if the string converts to a valid positive number, false if not
This is a function that will be useful in part 2. Do not add any elements to the HTML page for it. You can use the console to test it.
Part 2: Movie Ticket Price Add a heading, output paragraph, and button to the HTML page. Create a function for the button to call that uses two prompts to ask a user how old they are (in years) and the title of the movie they want to see. If either value is invalid, we will display an error message. Use the function from part 1 to validate the age value. If either value is invalid, display a message in the output paragraph explaining cl O The number is invalid if it is not a positive number (use your function from part 1) The title is invalid if it's length is 0 O If both values are valid, calculate the price of the ticket as follows. O The base price of the ticket is based on the length of the title. The movie costs $2 per character in the title. The minimum base price is $5 and the maximum is $30. Just check the length of the string, spaces, punctuation, numbers, etc, are all include in the length. If the string is too long or too short, you'll use the minimum/maximum price. O If the user is younger than 10 or older than 60, they receive a $3 discount to the base price. Display one of the following messages with the correct values based on the input/calculations You did not enter a valid age. You must enter a positive number. You did not enter a valid title. The title must have at least one character. A regular ticket for IT is $5 A discount ticket for IT is $2 A regular ticket for Ghostbusters costs $24 A discount ticket for Ghostbusters costs $21 A regular ticket for Everything Everywhere All At Once is $30 A discount ticket for Everything Everywhere All At Once is $27
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