@Vandesm14/

Swap Variables Values

Nodejs

Swap Variable Values in JavaScript with Variable Deconstruction

fork
loading
Files
  • index.js

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.21978897063683567","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"ZnVuY3Rpb24gcm9hZFJhZ2UoKSB7CiAgICBsZXQgcmlnaHRMYW5lID0gIkNoZXZ5IjsKICAgIGxldCBsZWZ0TGFuZSA9ICJIb25kYSI7CgogICAgbGV0IHN3YXAgPSBzd2FwTGFuZXMocmlnaHRMYW5lLCBsZWZ0TGFuZSk7IC8vIFtyaWdodExhbmUsIGxlZnRMYW5lXQogICAgbGVmdExhbmUgPSBzd2FwWzBdOyAvLyBbcmlnaHRMYW5lXQogICAgcmlnaHRMYW5lID0gc3dhcFsxXTsgLy8gW2xlZnRMYW5lXQoKICAgIHJldHVybiAoYFRoYXQgJHtyaWdodExhbmV9IGFuZCAke2xlZnRMYW5lfSB3b24ndCBwaWNrIGEgbGFuZWApOwp9Cgpyb2FkUmFnZSgpOwoKZnVuY3Rpb24gc3dhcExhbmVzKHJpZ2h0TGFuZSwgbGVmdExhbmUpIHsKICByZXR1cm4gW3JpZ2h0TGFuZSwgbGVmdExhbmVdOwp9"},"asBuffer":null},"loaded":true}}
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];
}
node v10.16.0