Answers for "swap two variables javascript"

8

javascript swap two variables

[a, b] = [b, a];
Posted by: Guest on July-03-2020
3

swap two variables javascript

var a = 1,
    b = 2;
b = [a, a = b][0];
Posted by: Guest on March-25-2020
2

swap in javascript

var first = 5;
var second = 7;
[first, second] = [second, first];
console.log(first, second);
//answer - 7 5
Posted by: Guest on August-07-2021
0

how do you swap the vaRIables js

let a = "red";
let b = "blue";
let c = a; // red
a = b; //over-rides to blue
b = c;

console.log(a);
console.log(b);
Posted by: Guest on February-26-2021

Code answers related to "swap two variables javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language