This question is related but is not the same as javascript: get a function's variable's value within another function & How do i pass variables between functions in javascript
I have been wondering for some time now how to pass a variable from one function to another, which answer can be found above. But the bigger question is how to pass multiple variable, sense the syntax of the answers found above can become overly complex, and it ends up being unreadable.
Don't mind the adding and alerting that I am doing in the example. This is a dummie example as stated below the exaple. The purpose of this question is clearly stated in the paragraph below in bold.
So here is my question, How do you pass multiple variable from one function to another, example:
function definingVars() {
var one = 1;
var two = 2;
var three = 3;
var four = 4;
var five = 5;
var six = 6;
var seven = 7;
var eight = 8;
var nine = 9;
var ten = 10;
}
function addingUp() {
definingVars();
alert("Alerting var total");
var total = one + two + three + four + five + six + seven + eight + nine;
alert(total);
alert("Alerting var ten");
alert(ten);
}
I know that it is not the correct way to approach this. But I'm trying to make a dummie example here.