Just need to replace it with a global regex search:
var data = cols[j].innerText.replace(/(\s\s)/gm, ' ').replace(/;/g, "\r\n")
Note sure what the \s\s is about tho but keeping it in there just in case (idk the format of your data)
\s\s