函数声明
前言
javaSE的运算符、选择语句、循环语句等都能在js使用,就不详细写在笔记里了
函数声明function
function 函数名(形参){}
<script>
function computed(n,m,op){
switch(op){
case "+":
return n+m;
break;
case "-":
return n-m;
break;
case "*":
return n*m;
break;
case "/":
return n/m;
break;
}
}
var result = computed(3,5,"*");
console.log(result);//15
</script>