Using the String methods indexOf( ) and replace( ) we can search a string for all instances of another string value and replace it.
The key is using a while loop.
This video shows how to solve this problem without using regular expressions.
NOTE: Around 8:40 in the video I talk about creating a copy of the paragraph. Since this is a JavaScript primitive value I did not have to use "".concat( ) to create the copy. I could have just passed it into a new variable.
let newParagraph = paragraph;
That would have copied it.
It is when you move beyond primitives that JavaScript passes by reference instead of value.
Code GIST: https://gist.github.com/prof3ssorSt3v...
On this page of the site you can watch the video online String Methods for Find and Replace with a duration of hours minute second in good quality, which was uploaded by the user Steve Griffith - Prof3ssorSt3v3 21 March 2018, share the link with friends and acquaintances, this video has already been watched 3,532 times on youtube and it was liked by 84 viewers. Enjoy your viewing!