Programming Example
Writing into an window alert box using Javascript
Writing into an window alert box using Javascript
<!DOCTYPE html>
<html>
<body>
<h2>Writing into an window alert box</h2>
<p>My first paragraph.</p>
<script>
window.alert(10 + 6);
</script>
</body>
</html>
<h3>Live Preview </h3>
<div class="shadow">
<img src="/library/images-tutorials/html-browser.png" class="img-thumbnail">
<div class="ratio ratio-16x9">
<iframe class="embed-responsive-item" src="/library/javascript/overview-of-javascript/window-alert-box-using-javascript-q-1022.html"></iframe>
</div>
</div> </div>
<hr>
When you will refresh this page one alert will be open with output value.
First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.
After understanding this example, try to rewrite the same program without looking at the code. Then change some values or logic and run it again. This helps improve confidence and keeps learners engaged on the page for longer.