SOURCE

function writeDocument(variable){
    document.write(variable+"<br/>")
}
var str = "Rome was not built in a day";  //定义字符串
var str = str.replace(/\s*/g,"");
var charCount = 0;

for (var ch of str) {

    charCount++;

}

writeDocument("该语句字符个数为:"+charCount);
console 命令行工具 X clear

                    
>
console