Friday 8 January 2021

Variable Declaration Using Java Script

 Java Script variables

Variable are containers that can stores user define values

Define variable using var sign

without any sign variable accessible are flexible and usable

______________________________________________________

Example 1:  Simple variable Declaraton

<script>    

    a = "jay";

    document.write(a);

</script>


Example 2: Simple Calculation

<script>

a=20;

b=30;

c = a+b;

document.write(c);

</script>


Example 3: Concatenate a  variables (Merge)

<script>

var a="jay";

var b="raj";

document.write(a+"<br>"); //single variable access

document.write(b+"<hr>"); //single variable access


/* Concating a Variable (Merge) */

document.write(a,b); //merge variable using (,) sign

document.write(a+b); //merge variable using + sign

</script>


Example 4: Simple Calculations with variable with HTML Formatting

<script>


x= 30;

y = 40;

z = x+y;

document.write("<font color=red>SUM IS: </font><font color=green>",z +"</font><br>");


z = x-y;

document.write("<font color=red>SUB IS: </font><font color=green>",z +"</font><br>");


z = x*y;

document.write("<font color=red>MUL IS: </font><font color=green>",z +"</font><br>");


z = x/y;

document.write("<font color=red>DIV IS: </font><font color=green>",z +"</font>");


</script>


___________________________________________

All Programming languages step by step with youtube.com/avadhtutor/playlists/



1 comment: