Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. function STRING(str, hash) {
  2. var new_str = str;
  3. for (var key in hash) {
  4. var regex = new RegExp(':' + key.toString(), "g");
  5. new_str = new_str.replace(regex, hash[key]);
  6. }
  7. return new_str;
  8. }
  9.  
  10.  
  11. var txt = STRING('testing this :first (:first) making :script', {
  12. first: 'FIRST',
  13. script: 'SCRIPT'
  14. });
  15.  
  16. document.write(txt);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement