Tell us what’s happening:
Describe your issue in detail here.
I have completed this challenge, but I still do not understand why in this part:
else if(before[0] == lowerLetter )
{
return str.replace(before, after.toLowerCase())
}
when i use strict equality operator, this test does not pass:
myReplace(“I think we should look up there”, “up”, “Down”)
but when I use equality operator, it passess
I already known the difference between these two, but I still do not understand why.Can you explain that to me, thank you
**Your code so far**
function myReplace(str, before, after) {
let upperCaseLetterInBefore = before.match(/[A-Z]/)
let lowerLetter = before.match(/[a-z]/)
if(before.indexOf(upperCaseLetterInBefore) === 0) {
return str.replace(before,after[0].toUpperCase() + after.slice(1) )
}
else if(before[0] == lowerLetter )
{
return str.replace(before, after.toLowerCase())
}
else
{
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 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Search and Replace
Link to the challenge: