Shows the code for the AssignValToVariable.html file.
<!doctype html>
<html>
<head>
<title>Declaring a variable</title>
</head>
<body>
<h1>Using a variable in the script</h1>
<SCRIPT type="text/javascript">
var countBooks=100;
document.write("Number of Books="+countBooks);
</SCRIPT>
</body>
</html>
Here We declared a variable named countBooks and assigned the value 100 to it.
The statement document.write ("Number of Books"+countBooks) prints the value of the countBooks variable. The + operator is used to append the two strings the text Number of Books= and the value of the countBooks variable.
Shows the output of the AssignValToVariable.html file.
No comments:
Post a Comment