Skip to content

Commit 6f168f8

Browse files
committed
Updated code
1 parent 854ff29 commit 6f168f8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
// Declare a function swap that takes num_1 and num_2 as parameters.
12
function swap(num_1,num_2){
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
36
let temp = num_1;
47
num_1 = num_2;
58
num_2 = temp
6-
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)
711
}

0 commit comments

Comments
 (0)