Skip to content

Instantly share code, notes, and snippets.

@layonthebeech
Created May 25, 2017 03:03
Show Gist options
  • Save layonthebeech/d081200eea24ee96f29e37e7daf62942 to your computer and use it in GitHub Desktop.
Save layonthebeech/d081200eea24ee96f29e37e7daf62942 to your computer and use it in GitHub Desktop.
var str = "aaaaaaaa";
var word = "aaa";
var ltr = "w";
var result = "";
for(var i = 0; i < str.length; i++) {
//console.log(str)
//console.log('1 ' + i + ' ' + ' ' + str.substring(i,i+word.length));
if(word == str.substring(i,i+word.length)) {
result += ltr;
i = i+word.length-1;
} else {
console.log('else');
result+=str[i];
}
//console.log('1 ' + i + ' ' + result)
console.log(i)
}
console.log('result', result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment