用javascript写第一个函数

<!DOCTYPE html>

<html lang="en">

 

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>Document</title>

<script>

function getSum(num1,num2){

var sum = 0;

for(var i = num1; i <= num2; i++){

sum += i;

}

console.log(sum);

}

getSum(1,100);

</script>

</head>

 

<body>

 

</body>

 

</html>

上一篇:重载的概念解析


下一篇:C#回调函数的简单讲解与应用例子,简单例子明白意义所在