In the following code, I want to assign new values to 3 variables inside a function. If I had only 1 variable, I could simply return the new value. Is there a simple way to do that with multiple variables inside one function (without using complicated methods such as turning the variables into an array and returning the array)?
Here is my code:
function increment(x, y, z) {
x += 1;
y += 2;
z += 3;
}
var a = 1;
var b = 1;
var c = 1;
var d = 20;
var e = 12;
var f = 8;
increment(a, b, c);
console.log(a + ", " + b + ", " + c);
increment(d, e, f);
console.log(d + ", " + e + ", " + f);
// desired output:
// 2, 3, 4
// 21, 14, 11
// actual output:
// 1, 1, 1
// 20, 12, 11