Preview:
<!DOCTYPE html>
<html>
<body>
​
<h2>JavaScript Functions</h2>
​
<p>This example calls a function which performs a calculation and returns the result:</p>
​
<p id="demo"></p>
​
<script>
var x = myFunction(4, 3);
document.getElementById("demo").innerHTML = x;
​
function myFunction(a, b) {
  return a * b;
}
</script>
​
</body>
</html>
​
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter