Question: What problem does the following code solve? Why would this not work, and how could you rectify the problem? var myString = This sentence has
What problem does the following code solve?
Why would this not work, and how could you rectify the problem?
var myString = "This sentence has has a fault and and we need to fix it." var myRegExp = /(\b\w+\b) \1/g; myString = myString.replace(myRegExp, "$1"); Now imagine that you change that code, so that you create the RegExp object like this: var myRegExp = new RegExp("(\b\w+\b) \1");
Step by Step Solution
3.42 Rating (152 Votes )
There are 3 Steps involved in it
The problem is that the sentence has has has and and and inside it clearly a mistake A lot of word p... View full answer
Get step-by-step solutions from verified subject matter experts
