Question
javascript A function call can be assigned to a HTML button's onclick-attribute. In this exercise we have a button with the attribute onclick=calcSquare(). The page
javascript
A function call can be assigned to a HTML button's onclick-attribute. In this exercise we have a button with the attribute onclick="calcSquare()".
The page also has a text input field () and a button. Clicking the button will call the function calcSquare(), which fetches the value in the input field, calculates its square, and prints it below the text input field in the form "The square of X is Y". The input field's id is "num" and the result is shown in an element with the id "result".
Write the function in question. Calling the function is done automatically by the test.
Example output:
The square of 19 is 361
The output of the program must be exactly the same as the example output (the most strict comparison level)
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