JAVASCRIPT OUTPUT


To run javascript one must mention how javascript must respond to HTML.So one needs to metion this.There are many ways to do this and all are mentioned beneath.
  • window.alert()-This function allows javascript to show output in an alert box.
  • document.write()-This function allows javascript to write results into new HTML web page.
  • innerHTML-This function replaces the previous HTML element with the one mentioned in it.
  • console.log()-This function shows the result within browser console.

window.alert()

Coding:

<!DOCTYPE html>
<html>
<head>
<title>
JAVASCRIPT OUTPUT
</title>
</head>
<body>
<button type="button" onclick="myFunction()">
Click Me! </button>t
<script>
function myFunction(){
window.alert(88-44);
}
</script>t
</body>
</html>

document.write()

Coding:

<!DOCTYPE html>
<html>
<head>
<title>
JAVASCRIPT OUTPUT
</title>
</head>
<body>
<button type="button" onclick="myFunction()">
Click Me! </button>t
<script>
function myFunction(){
document.write(88-44);
}
</script>t
</body>
</html>

innerHTML

Your output will be displayed here.

Coding:

<!DOCTYPE html>
<html>
<head>
<title>
JAVASCRIPT OUTPUT
</title>
</head>
<body>
<p id="output">
Your output will be displayed here.
</p>
<button type="button">
onclick="myFunction()">
Click Me! </button>t
<script>
function myFunction(){
document.getElementBy
Id("output").innerHTML=(88-44);
}
</script>t
</body>
</html>

console.log()

Coding:

<!DOCTYPE html>
<html>
<head>
<title>
JAVASCRIPT OUTPUT
</title>
</head>
<body>
<button type="button" onclick="myFunction()">
Click Me! </button>t
<script>
function myFunction(){
console.log(88-44);
}
</script>t
</body>
</html>