Last active
September 15, 2015 21:14
-
-
Save mgroves/d40f18b608ea93b049bb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function replaceASingleCharacter(str, singleCharacter, replaceWith) { | |
| // put regex replace here | |
| // something like return str.replace(/blahblahregex/,replaceWith); | |
| } | |
| var result1 = replaceASingleCharacter("This X should be replaced","X","Y"); | |
| if(result1 != "This Y should be replaced") { | |
| console.log("fail 1"); | |
| } | |
| var result2 = replaceASingleCharacter("These XX should NOT be replaced","X","Y"); | |
| if(result2 != "These XX should NOT be replaced") { | |
| console.log("fail 2"); | |
| } | |
| var result3 = replaceASingleCharacter("This X should be replaced, but the XX should not be","X","Y"); | |
| if(result3 != "This Y should be replaced, but the XX should not be") { | |
| console.log("fail 3"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment