SOURCE

var str ="Rome was not built in a day";
arr =str.replace(/\s/g);//去掉空格
var sum =0;
for(var i of str){
  sum++;
}
document.write(sum);
console 命令行工具 X clear

                    
>
console