EduCoder_web training homework--JavaScript learning manual eight: JS function

这一节有七关,而且都有难度。做完之后感觉太难了。。。。。。。。。 考察阅读能力

first round

//请在此处编写代码
/********** Begin **********/
function mainJs(a,b){
    
    
    return a+b;
}
/********** End **********/

Second level

	//请在此处编写代码
	/********** Begin **********/
var myFunc =function(b){
    
    
 var first = (b-b%100)/100;//求出百位数
        var second = (b%100-b%100%10)/10;//求出十位上的数
        var third = b-first*100-second*10;//求出各位数
        return first+second+third;

}   
	/********** End **********/

Third pass

//请在此处编写代码
	/********** Begin **********/
     if(a == 1) {
    
    
        return getMax(b,c);
    } else if(a == 2) {
    
    
        return getMin(b,c);
    } else {
    
    
        return myObject.myFunc(b,c);
    }
	/********** End **********/

Fourth level

//请在此处编写代码
	/********** Begin **********/
    
        a= a==  undefined?"green":a;
        b= b== undefined?"green":b;
        c= c== undefined?"red":c;
        d= d==undefined?"yellow":d;
 
    
    return a+"-"+b+"-"+c+"-"+d;
	/********** End **********/

Fifth level

//请在此处编写代码
/********** Begin **********/
function getMax(){
    
    
    var aLentgh = arguments.length;
    var max=0;
    for(var i=0;i<aLentgh;i++){
    
    
        if(arguments[i]>max){
    
    
            max=arguments[i];
        }
    }

    return max;
}

/********** End **********/

Sixth pass

//请在此处编写代码
/********** Begin **********/
 var res="";
for(var i in object){
    
    
   res+=i +":" + object[i]+",";
}
return res;
/********** End **********/

Seventh pass

//请在此处编写代码
	/********** Begin **********/
           return func(a);
	/********** End **********/

who I am?
Erxianqiao Traffic Commissioner
Chenghua Avenue is resident in Shanxi on behalf of
Pine Cone Flick 3D Hun Yuan Jin Leibel Master
Chen e University City Branch e
skip class tenth level expert
Welcome to pay attention to my public
account . Let us discuss learning and life
here. More resources are waiting for you.
Welcome to the online conversation!
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_45803282/article/details/112213393