File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
solutions/ch_15_Swap_Numbers Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 1
1
// Declare a function swap that takes num_1 and num_2 as parameters.
2
- function swap ( num_1 , num_2 ) {
2
+ function swap ( num_1 , num_2 ) {
3
3
// At first print the numbers before swaping
4
- console . log ( "Before swapping:\n num_1 = " + num_1 + "\n num_2 = " + num_2 )
4
+ console . log ( "Before swapping:\n num_1 = " + num_1 + "\n num_2 = " + num_2 ) ;
5
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
6
let temp = num_1 ;
7
- num_1 = num_2 ;
8
- num_2 = temp
7
+ num_1 = num_2 ;
8
+ num_2 = temp ;
9
9
// Check the result by printing the output
10
- console . log ( "After swapping:\n num_1 = " + num_1 + "\n num_2 = " + num_2 )
10
+ console . log ( "After swapping:\n num_1 = " + num_1 + "\n num_2 = " + num_2 ) ;
11
11
}
You can’t perform that action at this time.
0 commit comments