//check a string has substring or not
const str = ‘Har har Modi,Ghar-Ghar Modi.’;
const sub_str = ‘Modi’;
console.log(‘Is string has a substring? ‘,str.includes(sub_str))
// this is case senstive
//Get first index of a substring in string
const str_2 = ‘Har har Modi,Ghar-Ghar Modi.’;
const sub_str_2 = ‘Modi’;
console.log(‘First occurace of a substring : ‘,str_2.indexOf(sub_str_2))
//To check how much a substring occur in a string
const str_3 = ‘Har har Modi,Ghar-Ghar Modi.’;
const sub_str_3 = ‘Modi’;
console.log(‘Count of a substring in a string : ‘,(str_3.split(sub_str_3).length-1))
//To break a string in array by a substring
const str_4 = ‘Har har Modi,Ghar-Ghar Modi.’;
const sub_str_4 = ‘Modi’;
console.log(‘Break a string in array by a substring : ‘,(str_4.split(sub_str_4)))