Exercise no. 1:
<html>
<body>
<div id="demo">
Display the result here.</div>
<script>
var number = 50;
document.getElementById("demo").innerHTML = number;
</script>
</body>
</html>
Exercise no. 2:
<html>
<body>
<div id="demo">
</div>
<script>
var x = 5;
var y = 6;
var z = x + y;
document.getElementById("demo").innerHTML = z;
</script>
</body>
</html>
Exercise no. 3:
<html>
<body>
<div id="demo">
</div>
<script>
var x = 50;
document.getElementById("demo").innerHTML = x/3;
</script>
</body>
</html>
Exercise no. 4:
<html>
<body>
<div id="demo">
Display the result here.</div>
<script>
var x = 8;
var y = 5;
document.getElementById("demo").innerHTML = "The sum of " + x + " plus " + y + " is " + (x+y) + ".<br/>The product of " + x + " times " + y + " is " + (x*y) + "."
</script>
</body>
</html>
No comments:
Post a Comment