Created
January 13, 2020 13:30
-
-
Save qodirovshohijahon/92a4e6031259e3c411c8440efe816c66 to your computer and use it in GitHub Desktop.
In this example you will see swapping in js.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function swappingUsingTwoVars(num1, num2) { | |
num1 = num1 + num2; | |
num2 = num1 - num2; | |
num1 = num1 - num2; | |
return ("First number " + num1 + "\nSecond number " + num2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is the worst way of swapping coz it will be limitation in number's value that is number type may contain 2^32 in this ex 2^32 adding 2^32 that means wrong.But this is also method of swapping.