Practical - 7: Aim: (A)
Practical - 7: Aim: (A)
Code: 1 & 2
<html>
<head>
<script>
var a = parseInt(prompt("value"));
var fact=1;
//a=[10,20,30];
while (a >1)
{
fact=fact*a;
a=a-1;
}
document.write(fact);
console.log(fact);
alert(fact);
</script>
</head>
</html>
Code: 3
<html>
<head>
<script>
Output:
1 and 2)
Code:
<html>
<head>
<script>
var operand1 = parseInt(prompt("Enter Value 1:"));
var operand2 = parseInt(prompt("Enter Value 2:"));
var c = prompt("Enter the operator (+, -, *, /):");
var result=0;
switch(c)
{
case "+":
result = operand1 + operand2;
break;
case "-":
result = operand1 - operand2;
break;
case "*":
result = operand1 * operand2;
break;
case "/":
result = operand1 / operand2;
break;
default:
console.log("Invalid operator");
}
document.write(result)
</script>
Output:
Code:
<html>
<head>
<style>
form
{
border: 2px solid black;
width: 500px;
margin: 300 auto;
padding: 20px;
text-align: center;
}
</style>
</head>
<body>
<label for="zipcode">Zipcode:</label>
<input type="text" id="zipcode" name="zipcode" pattern="[0-9]{6}"
required><br><br>
Output: