Write a JavaScript code for swap any two numbers.
Write a JavaScript code forswap any two numbers.
<html>
<head>
<script type=text/javascript>
function swp(n1,n2)
{
n3=n1;
n1=n2;
n2=n3;
document.getElementById("one"). value=n1
document.getElementById("two"). value=n2
}
</script>
</head>
<body>
Enter first number:
<input type="number" id="one"><br><br>
Enter second number:
<input type="number" id="two"><br><br>
<input type="button" value="swap" onclick="swp(one.value,two.value);">
</body>
</html>
Output window looks like as:
Work in progress
ReplyDeleteHnn ji
Delete