Created
May 25, 2017 03:03
-
-
Save layonthebeech/d081200eea24ee96f29e37e7daf62942 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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