Skip to content

Commit 854ff29

Browse files
committed
Updated code
1 parent 70b3bf3 commit 854ff29

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function swap(num_1,num_2){
2-
console.log("Before swapping:\nnum_1 = "+num_1+"\nnum_2="+num_2)
2+
console.log("Before swapping:\nnum_1 = "+num_1+"\nnum_2 = "+num_2)
33
let temp = num_1;
44
num_1 = num_2;
55
num_2 = temp
6-
console.log("After swapping:\nnum_1 = "+num_1+"\nnum_2="+num_2)
6+
console.log("After swapping:\nnum_1 = "+num_1+"\nnum_2 = "+num_2)
77
}

solutions/ch_15_Swap_Numbers/readme.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,15 @@ function swap(num_1,num_2){
1717

1818
This function takes `num_1` and `num_2` and swaps their values. At first, the value of `num_1` is assigned to a variable `temp` then the value of `num_2` is assigned to `num_1`. Finally the value of `temp` assigned to `num_2`. The values are swapped.
1919

20-
21-
20+
Here's an example of usage of the function:
21+
```javascript
22+
swap(5,10)
23+
/*
24+
Before swapping:
25+
num_1 = 5
26+
num_2=10
27+
After swapping:
28+
num_1 = 10
29+
num_2=5
30+
*/
31+
```

0 commit comments

Comments
 (0)