function switchValues(n)
{
return 3 - n;
}
console.log(switchValues(1)); // 2
console.log(switchValues(2)); // 1
Click Run to execute JavaScript.
Code runs in an isolated environment.