Hello everyone!
I’m having some problem with this function. Maybe I’m missing something… the test is pass 3/5 and for some reason when I compare if the first charAt is UpperCase is still returning true when is not supposed to be true))
Please give me some kind of hint ![]()
Your code so far
function myReplace(str, before, after) {
var re = /^[A-Z]/ig;
return str.replace(before, function replacer(match){
return !re.test(match.charAt(0)) ? after : after.charAt(0).toUpperCase() + after.substring(1);
});
}
myReplace("Let us go to the store", "store", "mall");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36.
Link to the challenge:
https://www.freecodecamp.org/challenges/search-and-replace
