EduCoder_web training homework--JavaScript learning manual 9: common methods of strings

first round

//请在此处编写代码
	/********** Begin **********/
     var c=a.indexOf(b);
     var sum=0;
     while(c>=0){
    
    
         sum +=c;
         c=a.indexOf(b,c+b.length);
     }
    
    return sum;
	/********** End **********/

Second level

//请在此处编写代码
	/********** Begin **********/
    var i=0;
    var b="";
    while(i<6){
    
    
    
    b+= a.charAt(i);
   
    i++;
    }
    
    return b;
	/********** End **********/

Third pass

//请在此处编写代码
	/********** Begin **********/
    var c=a.indexOf(b)
    if(c!=-1){
    
    
        return(a.slice(0,c)+a.slice(b.length+c))
    }
    return a;
    
	/********** End **********/

Fourth level

//请在此处编写代码
	/********** Begin **********/
    var str =b.toUpperCase();
    for(var i=0;i<a.length;i++){
    
    
        s1=a.replace(new RegExp(b,"gm"),str);
    }    
    return s1
	/********** End **********/

Fifth level

	//请在此处编写代码
	/********** Begin **********/
  var spaceArray = a.split(" ");//以space分割
    var commaArray = a.split(",");//以逗号分隔
    return spaceArray.length+commaArray.length-1;
	/********** End **********/

who I am?
Two Xianqiao transport commissioner
, Permanent representative of Shanxi Chenghua Avenue
pineal bombs shake three-dimensional BI vaginal Master Jin
Chen e e University City sub-
skipping ten experts

welcome the public attention to my number
so that we can discuss learning about life
here as well 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/112303741