//1.
var str ="Rome was not built in a day";
var arr =str.replaceAll(" ","");//去掉所有的空格
var sum =0;
for(var i of arr)
{
sum++;
}
document.write(sum+"</br>");
//2.
function AbccbA(stringAbc) {
var stringcbA='';
for(var i=stringAbc.length-1;i>=0;i--){
stringcbA=stringcbA.concat(stringAbc.charAt(i));
}
return stringcbA;
}
document.write(AbccbA("sdadsd")+"</br>");
//3.
//for循环
function Cumsum(){
var sum=0;
//for循环
for(var i=0;i<=100;i++){
sum+=i;
}
return sum;
}
document.write(Cumsum()+"</br>");
//while循环
function Cumsum1(){
var sum=0;
//for循环
var i=0;
while(i<100){
i++;
sum+=i;
}
return sum;
}
document.write(Cumsum1()+"</br>");
//do while 循环
function Cumsum2(){
var sum=0;
//for循环
var i=0;
do{
i++;
sum+=i;
}while(i<100);
return sum;
}
document.write(Cumsum2()+"</br>");
console