The HTML page contains an element with the id “number”. The page calls a function calcSquare(), which has to fetch the value of the element, calculate its square (power of two), and print it in the console like so: “The square of X is Y”. Write this function. The HTML page in question will load your code, so you can refer to the page with the document keyword.
<body>
<p id="number">0</p>
<button id="button1"
onclick="calcSquare()">Click here!
</button>
</body>
Example output:
The square of … is …
The output of the program must be exactly the same as the example output (the most strict comparison level)
MY CODE:
function calcSquare() {
var number = document.getElementById("number").value;
Math.pow(number, 2);
}
console.log ("The square of" number "is" calcSquare)
That ID is given in the web page
Don’t understand how to write here console.log or maybe problem in the function??