SOURCE

function writeDocument(variable) {
    document.write(variable + "<br/>");
} 


var welcomeSteing= "welcome";

writeDocument(welcomeString);
writeDocument(welcomeString.length);

writeDocument("//case-------------------------------------------")
writeDocument(welcomeString.toLowerCase());
writeDocument(welcomeString.toUpperCase());
writeDocument("//charAt-------------------------------------------")
writeDocument(welcomeString.charAt(2));
writeDocument(welcomeString.charAt(6));
writeDocument("//substring-------------------------------------------")
writeDocument(welcomeString.substring(3));
writeDocument(welcomeString.substring(0, 2));
writeDocument("//replace-------------------------------------------")
var sentence = "We have fun in our class. Do you have fun in your class?"
writeDocument(sentence);
writeDocument(sentence.replace("class", "programming class"));
writeDocument(sentence.replace(/class/g, "programming class"));
writeDocument("//split-------------------------------------------")
var splitSentence = "We have fun in our class";
writeDocument(splitSentence);
writeDocument(splitSentence.split(" "));
writeDocument(welcomeString);
writeDocument(welcomeString.split(""));
writeDocument(sentence.split(""));
writeDocument("//IndexOf-------------------------------------------")
writeDocument(sentence.indexOf("class"));
writeDocument(sentence.lastIndexOf("class"));




function countChar(stringValue, char) {
    var charCount = 0;

    for (var i = 0; i < stringValue.length; ++i){
        if (stringValue.vharAt(i).toLowerCase() == char){
            ++charCount;
        }
    }

    return charCount;
} 
console 命令行工具 X clear

                    
>
console