Swap the values
There are many ways to solve this, but my favorite method is handling it through an array with a single statement.
var x=10, y =20 [x,y]= [y,x] // the y value will assigned to x and vice versa console.log(x,y)
From the above figure in the browser console you can notice the values are swapped between the two variables.
I hope you enjoyed this blog.
Happy coding, Cheers!!!