I want my Javascript to do this with a string...
Find the first instance of "aaa" and replace it with "xxx". Find the second instance of "aaa" and replace it with "yyy". Find the third instance of "aaa" and replace it with "zzz".
...and continue doing that until it no longer finds "aaa" in that string.
So for example, this string...
HELLO aaa WORLD aaa HERE aaa IS aaa SOME aaa RANDOM aaa TEXT aaa FOR aaa TESTING aaa
...will become this string...
HELLO xxx WORLD yyy HERE zzz IS xxx SOME yyy RANDOM zzz TEXT xxx FOR yyy TESTING zzz
I have Googled like hell about Javascript replacement, arrays, loops, etc., but everything I have tried has been unsuccessful. Any ideas from any Javascript coders out there?
By the way, I am not a jQuery user. So any code that relies on jQuery will not be useful for me.