Please tell me how to implement a javascript function that runs through the document body from beginning to end and replaces all odd occurrences of the search string str with str1 , and all even occurrences of str with str2 .
Theoretically, I understand that you need to start a certain cycle from the beginning to the end of the page, and write in this cycle something like this:
count = count +1; If count is odd, then replace the current element with str1
If count is even, then replace the current element with str2
What command can I use for this?