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?var myString = "This sentence has has a fault and and we

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

1 Expert Approved Answer
Step: 1 Unlock

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

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Beginning JavaScript Questions!