Tell us what’s happening:
Your code so far
function myReplace(str, before, after) {
if(before[0].toLowerCase() !== before[0]) {
after = after[0].toUpperCase() + after.slice(1)
}
return str.replace(before, after);
}
console.log(myReplace("I think we should look up there", "up","Down"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36
.
Challenge: Search and Replace
Link to the challenge:
what is your issue with this lesson? @rajeshkumar1
1 Like
ILM
4
what’s going wrong? what tests are not passing? what have you tried to fix that?
What will happen if your original word is lowercase and your replacement word is uppercase?
Also, do you want to check if before
is upper/lower case or do you need to check the instance of before
in your str
?
Thanks to all , got solution thanks again.
1 Like