We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5599ccd commit ea0ea5bCopy full SHA for ea0ea5b
problems/Problem11.js
@@ -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