function manipulateString(passedString1, passedString2) { var concatString; // The string passed to concat is added to the end of the first string concatString = passedString1.concat(passedString2); alert(concatString); // The following if statement will be true since first word is Tony if (concatString.charAt(3) == "y") { alert("Character found!"); } // The last position of the letter n is 10 alert("The last index of n is: " + concatString.lastIndexOf("n")); // A regular expression is used to locate and replace the substring var newString = concatString.replace(/Tony/gi,"General"); // The following yields Please salute General Patton alert("Please salute " + newString); // The match function returns an array containing all matches found matchArray = concatString.match(/Tony/gi); for (var i=0; i alert("Match found: " + matchArray[i]); } // Determine if the regular expression is found, a –1 indicates no if (newString.search(/Tony/) == -1) { alert("String not found"); } else { alert("String found."); } // Extract a portion of the string and store it in a new variable var sliceString = newString.slice(newString.indexOf("l")+2,newString.length); alert(sliceString); // The split function creates a new array containing each value separated by a space stringArray = concatString.split(" "); for (var i=0; i alert(stringArray[i]; } alert(newString.toUpperCase()); alert(newString.toLowerCase()); }