SOURCE

//有一个字符串"Rome was not built in a day",请用程序统计该字符串中字符的个数,不允许使用字符串对象的length属性。
var a ='Rome was not built in a day';
b =a.replace(/\s/g);//去掉所有的空格
var sum =0;
for(var i of a)
{
    sum++;
}
document.write('Rome was not built in a day字符串的个数有'+sum+'个');

console 命令行工具 X clear

                    
>
console