function getStr(str) { if(str.includes('aa')) { return str.replace(/aa/g,'') } return str } console.log(getStr('aaswaas'))