code: function replaceAll(str, find, replace) {
  	let s = '',
  		index,
  		next;
  	while (~(next = str.indexOf(find, index))) {
  		s += str.substring(index, next) + replace;
  		index = next + find.length;
  	}
  	return s + str.substring(index);
  }
docs: https://gist.github.com/developit/1a40a6fee65361d1182aaa22ab8c334c