亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

function with parameters

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 函數(shù)名(參數(shù)1,參數(shù)2)
{
     函數(shù)代碼
}

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.

Continuing Learning
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>函數(shù)傳參</title> <script type="text/JavaScript"> function add3(x,y,z) { sum = x + y +z; document.write(x+"、"+y+"、"+z+"和:"+sum+"<br/>"); } add3(5,8,3) ; add3(7,1,4); </script> </head> <body> </body> </html>
submitReset Code