I have a string that contains "..." in different places. And a string array with the same amount of words as the number of "...".
I want to replace all occurrences of "..." with the words from the string array.
let stringToReplace = "I want an ... that I get from the ..."
let stringArray = ["apple","shop"]
result = "I want an apple that I get from the shop"
I have tried this:
let result = stringToReplace;
for (let i = 0; i < stringArray.length; i++) {
let inloc = stringArray[i];
result = result.replace("...", inloc);
}
But that would only change the first occurrence of "...".