Hi everyone. I want you to check my code please and tell me where is the wrong.
function myReplace(str, before, after) {
if (/^[A-Z]/.test(before)){
after = after.slice(0,1).toUpperCase() + after.slice(1)
}
if(/^[A-Z]/.test(after)){
before = before.slice(0,1).toUpperCase() + before.slice(1)
}
return str.replace(before, after)
}
console.log(myReplace("I think we should look up there", "up", "Down"))