To get the returned value of a JavaScript function executed on an HTML page, here is an example:
<!DOCTYPE html>
<head>
<title>Function</title>
</head>
<body>
<button onclick="displayResult()">Result</button>
<p id="res"></p>
<script>
// JavaScript function that returns a value
function addNumbers(a, b) {
return a + b;
}
// Function to display the result on the page
function displayResult() {
let result = addNumbers(5, 3); // Call the function and store the result
document.getElementById("res").innerText = "Result is: " + result; // Display the result in the HTML
}
</script>
</body>
</html>