We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 854ff29 commit 6f168f8Copy full SHA for 6f168f8
solutions/ch_15_Swap_Numbers/answer.js
@@ -1,7 +1,11 @@
1
+// Declare a function swap that takes num_1 and num_2 as parameters.
2
function swap(num_1,num_2){
- console.log("Before swapping:\nnum_1 = "+num_1+"\nnum_2 = "+num_2)
3
+ // At first print the numbers before swaping
4
+ console.log("Before swapping:\n num_1 = "+num_1+"\n num_2 = "+num_2)
5
+ // Declare a variable temp and assigns the value of num_1 and assigns num_2 in num_1 and temp in num_2
6
let temp = num_1;
7
num_1 = num_2;
8
num_2 = temp
- console.log("After swapping:\nnum_1 = "+num_1+"\nnum_2 = "+num_2)
9
+ // Check the result by printing the output
10
+ console.log("After swapping:\n num_1 = "+num_1+"\n num_2 = "+num_2)
11
}
0 commit comments