The add2() function in the previous section cannot add any two specified numbers. In fact, the function definition can also be in the following format:
function 函数名(参数1,参数2) { 函数代码 }
Note: There can be multiple parameters, increase or decrease the number of parameters as needed. Parameters are separated by (comma,).
According to this format, the function to implement the sum of any two numbers should be written as:
function add2(x,y) { sum = x + y; document.write(sum); }
x and y are the two parameters of the function. When calling the function, we can pass these two The parameters pass the two actual addends to the function.
For example, add2(3,4) will find the sum of 3+4, and add2(60,20) will find the sum of 60 and 20.
Next Section