I have a function
function x10(a,b)
I define a
as an array a = [1]
. And the function x10
pushes b
zeros to a
x10 = function(a,b) {
output = a;
for(i=0;i<b;i++)
output.push(0);
return output;
}
I do NOT want this function to modify the argument a
. If I write
print(a)
y = x10(a,2)
print(a)
I want a to be the same. Instead I get a = [1]
before and a = [1,0,0]
after. How do I prevent a from changing while allowing y
to take the desired value.