let dummyString1 = "rock"; let dummyString2 = "Rock"; let pattern = new RegExp('^' + dummyString2 + '$', 'i'); if (pattern.test(dummyString1)) { console.log("String Matched"); } else { console.log("String Not Matched"); }