-
Notifications
You must be signed in to change notification settings - Fork 42
Strings
Mike edited this page May 28, 2014
·
1 revision
module.exports.formLetter = function(firstName, senderName, message) {
return "Hello " + firstName + ",\n\n" + message + "\n\nSincerely,\n" + senderName;
};
module.exports.sliceItAndCombineIt = function(bigString, startA, endA, startB, endB) {
return bigString.substring(startA, endA) + bigString.substring(startB, endB);
};
module.exports.findFirstMatch = function(text, searchString) {
return text.indexOf(searchString);
};
module.exports.findLastMatch = function(text, searchString) {
return text.lastIndexOf(searchString);
};
module.exports.substringBetweenMatches = function(text, searchString) {
firstMatchPosition = text.indexOf(searchString) + searchString.length;
lastMatchPosition = text.lastIndexOf(searchString);
return text.substring(firstMatchPosition, lastMatchPosition);
};