Swapping

 <!DOCTYPE html>

<html lang="en">

<head>

<title>Swapping</title>

</head>

<body>

<script>

var a=5;

var b=4;

var t;

document.write("Before swap"+"<br>");

document.write("a:"+a+"<br>");

document.write("b:"+b+"<br>");

t=a;

a=b;

b=t;

document.write("After swap"+"<br>");

document.write("a:"+a+"<br>");

document.write("b:"+b);

</script>

</body>

</html>

Comments

Popular posts from this blog

Calculate Factorial using While loop in JavaScript.

Calculator

Simple calculator