0% found this document useful (0 votes)
5 views4 pages

Understanding JavaScript Variables

Uploaded by

vani shree
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Understanding JavaScript Variables

Uploaded by

vani shree
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

JavaScript Variables

❮ PreviousNext ❯
 Using var
 Using let

 Using const

<html>

<head>

<script>

Js code

</script>

</head>

<body>

</body>

</html>

Var age=25;

Var name=”shree”

Var sal=12.2345;

<html>

<body>

<h1>JavaScript Variables</h1>

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

<script>
var x = 5;

var y = 6;

var z = x + y;

[Link]("The value of z is: " + z);

</script>

</body>

</html>

<!DOCTYPE html>

<html>

<body>

<h1>JavaScript Variables</h1>

<p>In this example, price, price2, and total are variables.</p>

<p id="demo"></p>

<script>

const price1 = 5;

const price2 = 6;
let total = price1 + price2;

[Link]("demo").innerHTML ="The total is: " + total;

</script>

</body>

</html>

<!DOCTYPE html>

<html>

<body>

<h2>JavaScript Variables</h2>

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

<p id="demo"></p>

<script>
let x = 5;

let y = 6;

let z = x + y;

[Link]("demo").innerHTML =

"The value of z is: " + z;

</script>

</body>

</html>

You might also like