repl.it
@Vandesm14/

Swap Variables Values

Nodejs

Swap Variable Values in JavaScript with Variable Deconstruction

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function roadRage() {
    let rightLane = "Chevy";
    let leftLane = "Honda";

    let swap = swapLanes(rightLane, leftLane); // [rightLane, leftLane]
    leftLane = swap[0]; // [rightLane]
    rightLane = swap[1]; // [leftLane]

    return (`That ${rightLane} and ${leftLane} won't pick a lane`);
}

roadRage();

function swapLanes(rightLane, leftLane) {
  return [rightLane, leftLane];
}
?