Skip to content

Instantly share code, notes, and snippets.

@kevin-miles
Last active August 29, 2015 14:12
Show Gist options
  • Save kevin-miles/196a397787b9c90ae8a9 to your computer and use it in GitHub Desktop.
Save kevin-miles/196a397787b9c90ae8a9 to your computer and use it in GitHub Desktop.
Dynamic Replacement of string parameters
//replaces a string's commas with spaces
var replacement = 'test';
//in my use i had a for loop that used the index to generate the value
//in this example if you had it in a loop it would replace each '$NUMBER' with 'test'
for(var i=0; i<5; i++){
final = final.split('$'+value).join(replacement);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment