Exerpad
Exercise 5 · Chapter: VariablesRequired+50 XP

Swap Values

You are given two variables. Swap their values and print both.

Your output should be:

a = 10
b = 5

Hint: You'll need a third variable to hold one value while you swap!

Need a hint?
3 available · costs 5 XP each
javascript
let a = 5;
let b = 10;

// Swap the values of a and b

console.log("a =", a);
console.log("b =", b);
Output
Run your code to see the output here.