Created
June 26, 2025 09:44
-
-
Save Gulshanidrees/0dd4aa17a85cc43423522f3f1bc3090b to your computer and use it in GitHub Desktop.
send me the code in javascript to swap two numbers
This file contains hidden or 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 swapNumbers(a, b) { | |
[a, b] = [b, a]; | |
return [a, b]; | |
} | |
let x = 10; | |
let y = 5; | |
let swapped = swapNumbers(x, y); | |
console.log(swapped); // Output: [5, 10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment