国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

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