var txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var str = "Please locate where 'locate' occurs!";
var str1 = "Apple, Banana, Kiwi";
var str2 = "Hello World!";
var len = txt.length;
var ind1 = str.indexOf("locate");
var ind2 = str.lastIndexOf("locate");
var ind3 = str.indexOf("locate", 15);
var ind4 = str.search("locate");
var res1 = str1.slice(7, 13);
var res2 = str1.slice(-12, -6);
var res3 = str1.slice(7);
var res4 = str1.slice(-12);
var res5 = str1.substring(7, 13);
var res6 = str1.substr(7, 9);
var res7 = str.replace("locate", "W3Schools");
var res8 = str.replace(/LOCATE/i, "W3Schools");
var res9 = str.replace(/LOCATE/g, "W3Schools");
var res10 = str2.toUpperCase();
var res11 = str2.toLowerCase();
document.write("<br>" + "Length of string:", len);
document.write("<br>" + "indexOf:", ind1);
document.write("<br>" + "index of last:", ind2);
document.write("<br>" + "indexOf with start point:", ind3);
document.write("<br>" + "search:", ind4);
document.write("<br>" + "slice:", res1);
document.write("<br>" + "slice -ve pos:", res2);
document.write("<br>" + "slice with only start pos:", res3);
document.write("<br>" + "slice with only -ve start pos", res4);
document.write("<br>" + "substring:", res5);
document.write("<br>" + "substr:", res6);
document.write("<br>" + "replace:", res7);
document.write("<br>" + "replace with case insensitive:", res8);
document.write("<br>" + "replace all:", res9);
document.write("<br>" + "to upper case:", res10);
document.write("<br>" + "to lower case:", res11);