You are on page 1of 4

<!

DOCTYPE html>

<html>

<body>

<h2>date function</h2>

<button type="button"

onclick="document.getElementById('mohan').innerHTML = Date()">

techinate show time and detail.</button>

<p id="mohan"></p>

</body>

</html>

JavaScript Variables can be declared in 4 ways:

• Automatically
• Using var
• Using let
• Using const

<!DOCTYPE html>

<html>

<body>

<h1>techinate JavaScript Variables</h1>

<p>In this example, x, y, and z are undeclared.</p>


<p id="mohan"></p>

<script>

x = 5;

y = 6;

z = x + y;

document.getElementById("mohan").innerHTML =

"The value of z is: " + z;

</script>

</body>

</html>

<script>

let x = 5;

let y = 6;

let z = x + y;

document.getElementById("mohan").innerHTML =

"The value of z is: " + z;

</script>

Function

<!DOCTYPE html>

<html>

<body>

<h1>techinate function</h1>
<p>Call a function which performs a calculation and returns the result:</p>

<p id="mohan"></p>

<script>

function myFunction(p1, p2) {

return p1 * p2;

let result = myFunction(4, 3);

document.getElementById("mohan").innerHTML = result;

</script>

</body>

</html>

<!DOCTYPE html>

<html>

<body>

<h1>techinate function</h1>

<p>Call a function which performs a calculation and returns the result:</p>

<p id="mohan"></p>

<script>

let x = myFunction(4, 3);


document.getElementById("mohan").innerHTML = x;

function myFunction(a, b) {

return a * b;

</script>

</body>

</html>

You might also like