SOURCE

// 问题1:实现字符串个数的输出
//对字符串进行切割(返回一个数组,用逗号隔开)
var spritsentence='Rome was not built in a day';
writeDocument("原句子为:"+spritsentence);
//对字符串进行切割(分隔符:空格)
writeDocument("拆分后每个元素为:"+spritsentence.split(''));
var count1=0;

for(var i=0;i<spritsentence.length;i++){
    count1++;
}
// 输出个数
writeDocument("字符串的个数为:"+count1);
//用于换行
function writeDocument(variable) {
    document.write(variable + "<br/>");
} 
console 命令行工具 X clear

                    
>
console