Swap the 2 number in the javascript
swaping the numer using javascript
<!DOCTYPE html>
<html>
<body>
<h2>My First JavaScript</h2>
<script>
var a = 4;
var b = 10;
a = a+b;
b= a-b;
a=a-b;
document.write("Step 1");
document.write("<br/>");
document.write("Value of a is :- " + a);
document.write("<br/>");
document.write("Value of a is :- " + b);
document.write("<br/>");
var a = 12;
var b = 15;
a = a^b;
b= a^b;
a=a^b;
document.write("Step 2");
document.write("<br/>");
document.write("Value of a is :- " + a);
document.write("<br/>");
document.write("Value of a is :- " + b);
document.write("<br/>");
document.write("Step 3");
var a = 4;
var b = 10;
[a,b] = [b,a]
document.write("<br/>");
document.write("Value of a is :- " + a);
document.write("<br/>");
document.write("Value of a is :- " + b);
document.write("<br/>");
</script>
</body>
</html>
Thanks you for commenting your questions. I will see question and respond you.