Tell us what’s happening:
Describe your issue in detail here.
Your code so far
function myReplace(str,before,after) {
if (before.match(/^[A-Z]/))
{after=after.charAt(0).
toUpperCase+after.slice(1);
}else {
after=after.charAt(0).toLowerCase+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 (Linux; Android 9; Infinix X652) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Mobile Safari/537.36
Challenge: Intermediate Algorithm Scripting - Search and Replace
Link to the challenge: