SOURCE

var str=prompt();
var zimu=0;
var shuzi=0;
var kongge=0;
var other=0;
for (var i=0;i<str.length;i++){
    if(str.charAt(i)>="A" && str.charAt(i)<="Z" || str.charAt(i)>="a" && str.charAt(i)<="z") {
        zimu++;
    } else if(str.charAt(i)==" ") {
        kongge++;
    } else if(str.charAt(i)>="0" && str.charAt(i)<="9") {
        shuzi++;
    } else {
        other++;
    }
}
document.write("字母:"+zimu);
document.write("数字:"+shuzi);
document.write("空格:"+kongge);
document.write("其他字符:"+other);
console 命令行工具 X clear

                    
>
console