Comp 110 string Methods

What is a string method?

Expressions of type string have special capabilities (AKA methods) that we can use to ask questions about the string data! All of these methods (used like functions) are accessible through TypeScript and do not have to be imported!

How do you use a string method?

<string expression>.<method name>(<arguments>);

string Methods Guide

Example of use:

let goHeels: string = "Beat Dook!";
let theLesserSchool: string = goHeels.substr(5,10);
//string 'theLesserSchool' is assigned the value "Dook!"
theLesserSchool = theLesserSchool.toLowerCase();
//'theLesserSchool' is reassigned "dook!"
let isWinning: boolean = theLesserSchool.includes("Luke Maye");
//boolean 'isWinning' is assigned FALSE 
//(the string "Luke Maye" is not found within the string "dook!")