SOURCE

console 命令行工具 X clear

                    
>
console
var str="Rome was not built in a day"
//定义一个字符串语句"Rome was not built in a day"

str=str.replace(/\s/g,'');
//先去掉所有空格

console.log(str)
//然后打印字符串

var sum=0;
//定义sum的初始值为0

for(var i of str){
  sum++
}
//用for循环统计该字符串中字符的个数
console.log(sum)
//打印字符串个数sum
<!DOCTYPE html> 
<html>
<head>
    <meta charset="utf-8" />   
</head>
<body>

    <script>
        


    </script>
</body>
</html>