Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Make a javascript file that will determine if a number is prime or not based on user input and will display if the number is
Make a javascript file that will determine if a number is prime or not based on user input and will display if the number is prime or not based on these parameters.
Your JavaScript code will declare its own variable labels to use to accomplish its task. The following "variable list" defines the labels you should use within your code SOURCE Prompt dialog Parsed into an Browser box Parsed from UI Repeatedly USAGE LABEL UI DESTINATION DESCRIPTION Data Type User Input of String number to test Test value acquired from user integer TVv Document TV Integer divided by DD to test for prime number status Loop index and test divisor Conditionally incremented and tested Division denominator Integer Set to TV HITS Quantity of Integer successful integer divisions Set to 0 Script Algorithm You are not required to analyze the steps necessary to accomplish the objective of the script. That work has already been done for you, resulting in an "algorithm" (logical recipe) as follows A. Start. B. Display a prompt dialog box and store the user's input in Ul i. Store Ul acquired from a prompt dialog box. ii. Parse Ul as a Base-10 integer and assign it to variable TV C. Initialize the HITS counter to zero D. Initialize the DD variable to the value of TV E. While DD is greater than zero, repeat the following block of two steps i. Test if TV is evenly divisible by DD (that is, if the remainder of TV/DD equals zero) If so, increment HITS by 1 ii. Decrement DD by 1 F. Display results within an HTML paragraph the browser's document window as seen in the Sample OUTPUT. The steps below must be performed in the order shown. i. Display the text stored in string UI ii. Display the string" is" iii. If HITS is greater than 2, then display the string" not" iv. Display the string" a prime number." G. EndStep 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