Dynamic expressions : Dynamic expressions « Statement « JavaScript Tutorial






<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
var num1, op, num2, ans;
num1 = prompt("Enter a number:","a number");

op = prompt("Enter an operator (+, -, *, / and %)", "operator");

num2 = prompt("Enter another number:", "a number");

ans = eval(Number(num1)+ op + Number(num2));

alert(num1 + " " + op + " " + num2 + " = " + ans);

//  -->
</script>
</head>
<body>

</body>
</html>








3.16.Dynamic expressions
3.16.1.Dynamic expressions