Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
function getName(name){
return "Welconme to" + name;
}
//调用
console.log(getName('朱老师'));
//重写
function getName(name,city){
return "欢迎来自"+city+"的"+name;
}
console.log(getName("谢老师","都匀"))
console.log(sum(600,800));
function sum(a=4,b){
return a +b;
}
console.log(sum(300));
//归并参数。rest
sum =function (... arr){
// console.log(arr);
// let res =0;
// for(let i=0; i<arr.length;i++){
// res += arr[i];
// }
// return res;
}
let a1 =[1,2,3,4,5,6,7];
//console.log(sum(1,2,3,4,5,6,7));
//console.log(sum(a1));
console.log(sum(...a1));
function getProduct(){
return [123,"手机",654987,"HUAWEI"];
}
let mobile=getProduct();
console.log(mobile);
console.log(mobile[3]);
function getProduct(){
return {id:123,name:"手机","my price":654987,brand:"HUAWEI"};
}
console.log(mobile["my price"]);
sum =(a,b) => {
return a +b;
};
console.log(sum(10,20));
/*
let getName=function(name){
return "hello" +name;
}
*/
getName=name =>{
return "Hello3"+ name;
}
console.log(getName("老猪"));
//单一函数 可以省略
sum=(a,b)=>a+b;
console.log(sum(80,50));
//声明
function sun(a,b){
return a+b;
};
//调用
console.log(sum(50,60));
//简化声明 用圆括号包住,使之转为表达式
(function sum(a,b){
console.log(a+b);
})(40,20);
</script>
</body>
</html>