DEV Community

Discussion on: Daily Challenge #259 - Duplicate Encoder

Collapse
 
moufeed_m profile image
Mofid Jobakji • Edited
const encoder = str =>
  str
    .toLowerCase()
    .replace(/\W|\w/g, (chr) =>
      str.indexOf(chr) === str.lastIndexOf(chr) ? '(' : ')'
    );