var welcomestring = "welcome";
writeDocument(welcomestring+"<br/>"+length+"<br/>");
writeDocument(welcomestring.toLocaleLowerCase()+"<br/>");
writeDocument(welcomestring.toLocaleUpperCase()+"<br/>");
writeDocument("case1---------------------------------------------------------");
function writeDocument(variable) {
document.write(variable + "<br/>");
}
writeDocument(welcomestring)
writeDocument(welcomestring.length)
document.write("case2---------------------------------------------------------");
writeDocument(welcomestring.toLocaleLowerCase())
writeDocument(welcomestring.toLocaleUpperCase())
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 class have nice tomorrow class"
writeDocument(sentence);
writeDocument(sentence.replace("class","programming"));
writeDocument(sentence.replace(/class/g,"programming"));
writeDocument("split---------------------------------------------------------");
var splitSentence="we havek sjalkj 1ssakljl1"
writeDocument(splitSentence);
writeDocument(splitSentence.split(" "));
writeDocument(welcomestring)
writeDocument(splitSentence.split(" "));
writeDocument(splitSentence.split(""));
writeDocument("IndexOf---------------------------------------------------------");
writeDocument(sentence.indexOf("class"));
writeDocument(sentence.lastIndexOf("class"));
writeDocument(sentence.match("class"));
writeDocument(sentence.match(/class/g));
writeDocument(sentence.search(/class/g));
writeDocument("---------------------------------------------------------");
var str="Can you can a can as a Canner can can a can"
function countChar(stringValue, char){
var charcount=0
for(var i=0; i< stringValue.length;i++)
{
if(stringValue.charAt(i).toLocaleLowerCase()==char)
{
charcount++;
}
}
return charcount;
}
writeDocument("There are "+countChar(str, "c")+" in sentence")
console