Skip to content

Commit ea0ea5b

Browse files
authored
Create Problem11.js
1 parent 5599ccd commit ea0ea5b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

problems/Problem11.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Swap Two Array Elements by Destructuring
2+
3+
const swapElements = (arr, x , y ) =>{
4+
[arr[x] , arr[y]] = [arr[y], arr[x]];
5+
}
6+
const arr = [ 3 , 2 , 5 , 9 , 12];
7+
console.log(arr);//before swaping
8+
swapElements(arr,1,3);
9+
console.log(arr);//after swapping

0 commit comments

Comments
 (0)