1.累加求和
function sum(...reset){
var s = 0
for (i=arguments.length-1;i>=0;i--){
s += reset[i];
}
return s;
}
sum(1,2,3,4)
2.求圆的面积
function area_of_circle(r,pi=3.14){
area = r * r * pi;
return area;
}
area_of_circle(2,3.1416)
// 测试:
if (area_of_circle(2) === 12.56 && area_of_circle(2, 3.1416) === 12.5664) {
console.log('测试通过');
} else {
console.log('测试失败');
}