


These are examples of checking if a string contains substrings in typescript using the include() method. To compile the code run the below command and you can see the result in the console: ts-node containsSubstringĬheck if the string contains the substring in the typescript Open the code editor, create a file named ‘containsSubstring.ts’, and then write the below code: let str= 'hey! i am typescript. Let’s see how we can implement the include(), to check if the string contains a substring.Įxample 1: We will take a string and we will find a substring from that string, if it is available then it returns true or else false.
