How exactly Functions with return and global Variables works
Hello, today we will see, how functions work, in which command return is. We have defined the function increaseValue, which increases the variable A by the value 2 and at the same time returns the variable A with the command return. In the next step, we define that the value of the variable B should be equal to the value that the function increaseValue returns.
The question arises as to what the value of variable A will now be, and the answer is that as soon as we call the function increaseValue, this function returns the value of variable A to variable B, but before the return statement this function also increases variable A by 2.
Variable A thus will have a value 2 now and the same value will have variable B, in which this value function increaseValue returns.
We can now start the page and see that both variables have a value of 2.
Thank you for watching this video and if you like, subscribe to this channel and put like.