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
Get step-by-step solutions from verified subject matter experts
