You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function s(){a="kdg by the dj,/nThe g care dg, I'm sure./nSo if cdg on the dj,/nThen I'm sure cdj g.".replace(/c|k/g,function(match){return(match=="c")?"she sells ":"She sells ";});c=a.replace(/d|g/g,function(match){return(match=="d")?"sea":"shells";});return (c.replace(/j/g,"shore"));}
1. Use shorter variable names (271: -16):
function s(){a="kdg by the dj,/nThe g care dg, I'm sure./nSo if cdg on the dj,/nThen I'm sure cdj g.".replace(/c|k/g,function(m){return(m=="c")?"she sells ":"She sells ";});c=a.replace(/d|g/g,function(m){return(m=="d")?"sea":"shells";});return (c.replace(/j/g,"shore"));}
_=>{a="kdg by the dj,/nThe g care dg, I'm sure./nSo if cdg on the dj,/nThen I'm sure cdj g.".replace(/c|k/g,m=>(m=="c")?"she sells ":"She sells ");c=a.replace(/d|g/g,m=>(m=="d")?"sea":"shells");return (c.replace(/j/g,"shore"))}
3. Remove return, braces and chain calls to replace (208: -19):
_=>"kdg by the dj,/nThe g care dg, I'm sure./nSo if cdg on the dj,/nThen I'm sure cdj g.".replace(/c|k/g,m=>(m=="c")?"she sells ":"She sells ").replace(/d|g/g,m=>(m=="d")?"sea":"shells").replace(/j/g,"shore")
4. Use string literals [this also renders as expected ;)] (204: -4):
_=>`kdg by the dj, The g care dg, I'm sure. So if cdg on the dj, Then I'm sure cdj g.`.replace(/c|k/g,m=>(m=="c")?"she sells ":"She sells ").replace(/d|g/g,m=>(m=="d")?"sea":"shells").replace(/j/g,"shore")
5. Combine replacements into an object literal (177: -27):
_=>`kdg by the dj, The g care dg, I'm sure. So if cdg on the dj, Then I'm sure cdj g.`.replace(/c|k|d|g|j/g,m=>({c:"she sells ",k:"She sells ",d:"sea",g:"shells",j:"shore"}[m]))
_=>`123 by the 24, The 3 0are 23, I'm sure. So if 023 on the 24, Then I'm sure 024 3.`.replace(/\d/g,m=>["she sells ","She sells ","sea","shells","shore"][m])