Microsoft MakeCode

Modify variables in a function

Why is it not possible to modify the value of a variable in a function when using blocks but works when using python? If i call the function with say 2 arguments (numbers) and in the function definition, how do I set/change the value of the function parameters?

1 Like

What I did is create a global variable that is the same name as the parameter you want to modify and then used the blocks to modify the global variable but since there is a parameter with the same name as the global variable in a function, it gets “shadowed” by the local variable so, in reality, you are actually modifying the local variable. I’ve tried this and it seems to work.