How do I swap the values of my function?
AndresHaro1 (0)

function roadRage() {
let rightLane = "Chevy";
let leftLane = "Honda";

//Write your code here to make the cars switch lanes
let Chevy = leftLane;
let Honda = rightLane;
return (`That ${rightLane} and ${leftLane} won't pick a lane`)



You are viewing a single comment. View All
mwilki7 (502)

2 variables can't give and receive a new value at the same time so you need a third variable to do some place holding

Here is an example of swapping 'a' and 'b':

    temp = a        <--- save a copy of 'a' for later
    a = b
    b = temp        <--- can't do 'a' because 'a' currently equals 'b'