Practical Aim:
JavaScript and HTML code to calculate power of given number
Code
calculatepowerofnumber.html file
<html>
<head>
<title>JavaScript Math pow() Method</title>
<style>
.wrapper{
padding:10px;
margin: 20px;
background-color: blue;
color: aliceblue;
}
input{
height: 20px;
}
button{
padding: 10px;
}
</style>
<script>
function powerof(){
var base = document.getElementById("base").value;
var power = document.getElementById("power").value;
var value = Math.pow(base, power);
document.getElementById("result").innerHTML ="Output: " + value;
}
</script>
</head>
<body>
<div class="wrapper">
<h1>Use JavaScript and HTML to calculate power of given number.</h1>
<p>Example: 7 raised to the power of 2 ( 7<sup>2</sup>) = 49</p>
<input type="number" id="base" placeholder="Enter Base Number"> raised to the power of <input placeholder="Enter Power Number" type="number" id="power">
<input type="button" onclick="powerof() " value="Calculate"><br> <br>
<div id="result">Output: </div>
</div>
</body>
</html>
Try here
<!DOCTYPE html >
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<h1> Try your code here</h1>
</body>
</html>
Output
0 Comments